webruby 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (258) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webruby/rake/mruby.rake +1 -0
  3. data/modules/emscripten/AUTHORS +7 -0
  4. data/modules/emscripten/LICENSE +26 -0
  5. data/modules/emscripten/emcc +58 -20
  6. data/modules/emscripten/emlink.py +2 -265
  7. data/modules/emscripten/emscripten.py +38 -18
  8. data/modules/emscripten/scons-tools/emscripten.py +11 -6
  9. data/modules/emscripten/scons-tools/llvm.py +4 -3
  10. data/modules/emscripten/src/analyzer.js +32 -13
  11. data/modules/emscripten/src/embind/embind.js +13 -13
  12. data/modules/emscripten/src/embind/emval.js +8 -7
  13. data/modules/emscripten/src/intertyper.js +10 -0
  14. data/modules/emscripten/src/jsifier.js +28 -6
  15. data/modules/emscripten/src/library.js +2949 -1322
  16. data/modules/emscripten/src/library_browser.js +27 -23
  17. data/modules/emscripten/src/library_egl.js +7 -2
  18. data/modules/emscripten/src/library_gl.js +15 -2
  19. data/modules/emscripten/src/library_glut.js +1 -1
  20. data/modules/emscripten/src/library_jansson.js +1 -1
  21. data/modules/emscripten/src/library_openal.js +464 -132
  22. data/modules/emscripten/src/library_path.js +134 -0
  23. data/modules/emscripten/src/library_sdl.js +222 -50
  24. data/modules/emscripten/src/modules.js +22 -5
  25. data/modules/emscripten/src/parseTools.js +13 -2
  26. data/modules/emscripten/src/postamble.js +60 -34
  27. data/modules/emscripten/src/preamble.js +67 -18
  28. data/modules/emscripten/src/relooper/Relooper.cpp +1 -1
  29. data/modules/emscripten/src/runtime.js +12 -2
  30. data/modules/emscripten/src/settings.js +869 -826
  31. data/modules/emscripten/src/shell.js +63 -51
  32. data/modules/emscripten/src/utility.js +6 -0
  33. data/modules/emscripten/system/include/bsd/sys/mman.h +1 -1
  34. data/modules/emscripten/system/include/emscripten/bind.h +28 -28
  35. data/modules/emscripten/system/include/libc/math.h +8 -0
  36. data/modules/emscripten/system/include/libc/sys/signal.h +3 -1
  37. data/modules/emscripten/system/include/libc/sys/stat.h +2 -1
  38. data/modules/emscripten/system/include/libc/sys/types.h +4 -0
  39. data/modules/emscripten/system/include/libcxx/CREDITS.TXT +24 -0
  40. data/modules/emscripten/system/include/libcxx/__bit_reference +27 -8
  41. data/modules/emscripten/system/include/libcxx/__config +62 -15
  42. data/modules/emscripten/system/include/libcxx/__debug +5 -1
  43. data/modules/emscripten/system/include/libcxx/__functional_03 +24 -24
  44. data/modules/emscripten/system/include/libcxx/__functional_base +22 -4
  45. data/modules/emscripten/system/include/libcxx/__hash_table +566 -54
  46. data/modules/emscripten/system/include/libcxx/__locale +11 -3
  47. data/modules/emscripten/system/include/libcxx/__split_buffer +6 -6
  48. data/modules/emscripten/system/include/libcxx/__std_stream +58 -30
  49. data/modules/emscripten/system/include/libcxx/__tree +58 -51
  50. data/modules/emscripten/system/include/libcxx/__tuple +9 -9
  51. data/modules/emscripten/system/include/libcxx/algorithm +223 -13
  52. data/modules/emscripten/system/include/libcxx/array +18 -17
  53. data/modules/emscripten/system/include/libcxx/atomic +15 -5
  54. data/modules/emscripten/system/include/libcxx/cctype +2 -2
  55. data/modules/emscripten/system/include/libcxx/chrono +131 -36
  56. data/modules/emscripten/system/include/libcxx/cmath +41 -36
  57. data/modules/emscripten/system/include/libcxx/complex +49 -49
  58. data/modules/emscripten/system/include/libcxx/cstdio +2 -2
  59. data/modules/emscripten/system/include/libcxx/cstdlib +5 -5
  60. data/modules/emscripten/system/include/libcxx/cstring +2 -2
  61. data/modules/emscripten/system/include/libcxx/cwchar +22 -13
  62. data/modules/emscripten/system/include/libcxx/deque +27 -14
  63. data/modules/emscripten/system/include/libcxx/forward_list +36 -35
  64. data/modules/emscripten/system/include/libcxx/fstream +16 -0
  65. data/modules/emscripten/system/include/libcxx/functional +348 -23
  66. data/modules/emscripten/system/include/libcxx/future +66 -0
  67. data/modules/emscripten/system/include/libcxx/ios +27 -0
  68. data/modules/emscripten/system/include/libcxx/istream +2 -4
  69. data/modules/emscripten/system/include/libcxx/iterator +17 -9
  70. data/modules/emscripten/system/include/libcxx/limits +2 -2
  71. data/modules/emscripten/system/include/libcxx/list +165 -105
  72. data/modules/emscripten/system/include/libcxx/locale +154 -43
  73. data/modules/emscripten/system/include/libcxx/map +165 -224
  74. data/modules/emscripten/system/include/libcxx/memory +113 -54
  75. data/modules/emscripten/system/include/libcxx/random +2 -29
  76. data/modules/emscripten/system/include/libcxx/readme.txt +1 -1
  77. data/modules/emscripten/system/include/libcxx/regex +60 -15
  78. data/modules/emscripten/system/include/libcxx/sstream +124 -40
  79. data/modules/emscripten/system/include/libcxx/string +345 -182
  80. data/modules/emscripten/system/include/libcxx/support/win32/limits_win32.h +3 -3
  81. data/modules/emscripten/system/include/libcxx/support/win32/locale_win32.h +15 -2
  82. data/modules/emscripten/system/include/libcxx/support/win32/math_win32.h +3 -3
  83. data/modules/emscripten/system/include/libcxx/support/win32/support.h +10 -11
  84. data/modules/emscripten/system/include/libcxx/thread +2 -2
  85. data/modules/emscripten/system/include/libcxx/tuple +134 -65
  86. data/modules/emscripten/system/include/libcxx/type_traits +232 -24
  87. data/modules/emscripten/system/include/libcxx/unordered_map +314 -161
  88. data/modules/emscripten/system/include/libcxx/unordered_set +160 -2
  89. data/modules/emscripten/system/include/libcxx/utility +225 -40
  90. data/modules/emscripten/system/include/libcxx/vector +52 -57
  91. data/modules/emscripten/system/include/net/if.h +20 -1
  92. data/modules/emscripten/system/include/net/netinet/in.h +69 -5
  93. data/modules/emscripten/system/include/netdb.h +36 -0
  94. data/modules/emscripten/system/include/sys/ioctl.h +55 -3
  95. data/modules/emscripten/system/include/sys/select.h +2 -0
  96. data/modules/emscripten/system/include/sys/sendfile.h +16 -0
  97. data/modules/emscripten/system/include/sys/socket.h +181 -35
  98. data/modules/emscripten/system/lib/dlmalloc.c +10 -12
  99. data/modules/emscripten/system/lib/libc/musl/src/stdlib/ecvt.c +19 -0
  100. data/modules/emscripten/system/lib/libc/musl/src/stdlib/fcvt.c +25 -0
  101. data/modules/emscripten/system/lib/libc/musl/src/stdlib/gcvt.c +8 -0
  102. data/modules/emscripten/system/lib/libcextra.symbols +3 -0
  103. data/modules/emscripten/system/lib/libcxx/CREDITS.TXT +24 -0
  104. data/modules/emscripten/system/lib/libcxx/debug.cpp +11 -9
  105. data/modules/emscripten/system/lib/libcxx/exception.cpp +9 -0
  106. data/modules/emscripten/system/lib/libcxx/hash.cpp +6 -0
  107. data/modules/emscripten/system/lib/libcxx/iostream.cpp +4 -4
  108. data/modules/emscripten/system/lib/libcxx/locale.cpp +91 -42
  109. data/modules/emscripten/system/lib/libcxx/readme.txt +1 -1
  110. data/modules/emscripten/system/lib/libcxx/stdexcept.cpp +1 -1
  111. data/modules/emscripten/system/lib/libcxx/string.cpp +332 -491
  112. data/modules/emscripten/system/lib/libcxx/support/win32/locale_win32.cpp +4 -2
  113. data/modules/emscripten/system/lib/libcxx/support/win32/support.cpp +140 -41
  114. data/modules/emscripten/system/lib/libcxx/symbols +9 -256
  115. data/modules/emscripten/system/lib/libcxx/system_error.cpp +3 -0
  116. data/modules/emscripten/system/lib/libcxx/thread.cpp +16 -3
  117. data/modules/emscripten/system/lib/libcxx/typeinfo.cpp +12 -2
  118. data/modules/emscripten/third_party/stb_image.c +4673 -0
  119. data/modules/emscripten/tools/asm_module.py +273 -0
  120. data/modules/emscripten/tools/exec_llvm.py +2 -2
  121. data/modules/emscripten/tools/file_packager.py +36 -16
  122. data/modules/emscripten/tools/find_bigfuncs.py +9 -9
  123. data/modules/emscripten/tools/js-optimizer.js +485 -131
  124. data/modules/emscripten/tools/js_optimizer.py +22 -15
  125. data/modules/emscripten/tools/merge_asm.py +26 -0
  126. data/modules/emscripten/tools/nativize_llvm.py +2 -2
  127. data/modules/emscripten/tools/settings_template_readonly.py +1 -1
  128. data/modules/emscripten/tools/shared.py +63 -20
  129. data/modules/emscripten/tools/split_asm.py +30 -0
  130. data/modules/emscripten/tools/test-js-optimizer-asm-outline1-output.js +686 -0
  131. data/modules/emscripten/tools/test-js-optimizer-asm-outline1.js +263 -0
  132. data/modules/emscripten/tools/test-js-optimizer-asm-outline2-output.js +747 -0
  133. data/modules/emscripten/tools/{test-js-optimizer-asm-outline.js → test-js-optimizer-asm-outline2.js} +1 -1
  134. data/modules/emscripten/tools/test-js-optimizer-asm-outline3-output.js +28 -0
  135. data/modules/emscripten/tools/test-js-optimizer-asm-outline3.js +30 -0
  136. data/modules/emscripten/tools/test-js-optimizer-asm-pre-output.js +4 -4
  137. data/modules/mruby/AUTHORS +1 -0
  138. data/modules/mruby/README.md +4 -2
  139. data/modules/mruby/build_config.rb +6 -6
  140. data/modules/mruby/doc/mrbgems/README.md +4 -4
  141. data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/mrbgem.rake +1 -1
  142. data/modules/mruby/examples/mrbgems/c_extension_example/mrbgem.rake +1 -1
  143. data/modules/mruby/examples/mrbgems/ruby_extension_example/mrbgem.rake +1 -1
  144. data/modules/mruby/include/mrbconf.h +3 -0
  145. data/modules/mruby/include/mruby/array.h +2 -2
  146. data/modules/mruby/include/mruby/class.h +4 -4
  147. data/modules/mruby/include/mruby/compile.h +1 -0
  148. data/modules/mruby/include/mruby/data.h +1 -1
  149. data/modules/mruby/include/mruby/hash.h +2 -2
  150. data/modules/mruby/include/mruby/irep.h +3 -2
  151. data/modules/mruby/include/mruby/proc.h +1 -1
  152. data/modules/mruby/include/mruby/range.h +1 -1
  153. data/modules/mruby/include/mruby/string.h +2 -2
  154. data/modules/mruby/include/mruby/value.h +43 -26
  155. data/modules/mruby/include/mruby.h +10 -2
  156. data/modules/mruby/minirake +2 -2
  157. data/modules/mruby/mrbgems/mruby-array-ext/mrbgem.rake +1 -1
  158. data/modules/mruby/mrbgems/mruby-bin-mirb/mrbgem.rake +4 -1
  159. data/modules/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +32 -0
  160. data/modules/mruby/mrbgems/mruby-bin-mruby/mrbgem.rake +1 -1
  161. data/modules/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +13 -5
  162. data/modules/mruby/mrbgems/mruby-enum-ext/mrbgem.rake +1 -1
  163. data/modules/mruby/mrbgems/mruby-enum-ext/test/enum.rb +10 -11
  164. data/modules/mruby/mrbgems/mruby-eval/mrbgem.rake +1 -1
  165. data/modules/mruby/mrbgems/mruby-exit/mrbgem.rake +4 -0
  166. data/modules/mruby/mrbgems/mruby-exit/src/mruby-exit.c +24 -0
  167. data/modules/mruby/mrbgems/mruby-fiber/mrbgem.rake +1 -1
  168. data/modules/mruby/mrbgems/mruby-fiber/src/fiber.c +4 -2
  169. data/modules/mruby/mrbgems/mruby-hash-ext/mrbgem.rake +1 -1
  170. data/modules/mruby/mrbgems/mruby-hash-ext/test/hash.rb +5 -7
  171. data/modules/mruby/mrbgems/mruby-math/mrbgem.rake +1 -1
  172. data/modules/mruby/mrbgems/mruby-numeric-ext/mrbgem.rake +1 -1
  173. data/modules/mruby/mrbgems/mruby-numeric-ext/test/numeric.rb +2 -2
  174. data/modules/mruby/mrbgems/mruby-object-ext/mrbgem.rake +1 -1
  175. data/modules/mruby/mrbgems/mruby-object-ext/src/object.c +3 -3
  176. data/modules/mruby/mrbgems/mruby-object-ext/test/nil.rb +3 -3
  177. data/modules/mruby/mrbgems/mruby-object-ext/test/object.rb +1 -1
  178. data/modules/mruby/mrbgems/mruby-objectspace/mrbgem.rake +1 -1
  179. data/modules/mruby/mrbgems/mruby-objectspace/test/objectspace.rb +36 -37
  180. data/modules/mruby/mrbgems/mruby-print/mrbgem.rake +1 -1
  181. data/modules/mruby/mrbgems/mruby-proc-ext/mrbgem.rake +1 -1
  182. data/modules/mruby/mrbgems/mruby-proc-ext/test/proc.rb +8 -8
  183. data/modules/mruby/mrbgems/mruby-random/mrbgem.rake +1 -1
  184. data/modules/mruby/mrbgems/mruby-range-ext/mrbgem.rake +1 -1
  185. data/modules/mruby/mrbgems/mruby-range-ext/test/range.rb +6 -6
  186. data/modules/mruby/mrbgems/mruby-sprintf/mrbgem.rake +1 -1
  187. data/modules/mruby/mrbgems/mruby-string-ext/mrbgem.rake +1 -1
  188. data/modules/mruby/mrbgems/mruby-string-ext/test/string.rb +6 -6
  189. data/modules/mruby/mrbgems/mruby-struct/mrbgem.rake +1 -1
  190. data/modules/mruby/mrbgems/mruby-symbol-ext/mrbgem.rake +1 -1
  191. data/modules/mruby/mrbgems/mruby-symbol-ext/test/symbol.rb +2 -2
  192. data/modules/mruby/mrbgems/mruby-time/mrbgem.rake +1 -1
  193. data/modules/mruby/mrbgems/mruby-time/src/time.c +2 -8
  194. data/modules/mruby/mrbgems/mruby-toplevel-ext/mrbgem.rake +1 -1
  195. data/modules/mruby/mrbgems/mruby-toplevel-ext/test/toplevel.rb +10 -10
  196. data/modules/mruby/mrblib/class.rb +15 -9
  197. data/modules/mruby/mrblib/string.rb +12 -0
  198. data/modules/mruby/src/array.c +4 -3
  199. data/modules/mruby/src/class.c +13 -8
  200. data/modules/mruby/src/codegen.c +9 -8
  201. data/modules/mruby/src/error.c +7 -5
  202. data/modules/mruby/src/error.h +1 -0
  203. data/modules/mruby/src/etc.c +1 -1
  204. data/modules/mruby/src/gc.c +163 -128
  205. data/modules/mruby/src/kernel.c +43 -15
  206. data/modules/mruby/src/numeric.c +9 -7
  207. data/modules/mruby/src/object.c +1 -1
  208. data/modules/mruby/src/parse.y +37 -19
  209. data/modules/mruby/src/range.c +10 -24
  210. data/modules/mruby/src/state.c +2 -6
  211. data/modules/mruby/src/string.c +0 -9
  212. data/modules/mruby/src/variable.c +2 -2
  213. data/modules/mruby/src/vm.c +12 -6
  214. data/modules/mruby/tasks/mrbgem_spec.rake +7 -0
  215. data/modules/mruby/tasks/mrbgems.rake +2 -1
  216. data/modules/mruby/tasks/mrbgems_test.rake +1 -1
  217. data/modules/mruby/tasks/mruby_build.rake +4 -3
  218. data/modules/mruby/tasks/mruby_build_commands.rake +6 -1
  219. data/modules/mruby/tasks/mruby_build_gem.rake +2 -2
  220. data/modules/mruby/tasks/toolchains/androideabi.rake +2 -0
  221. data/modules/mruby/test/assert.rb +2 -2
  222. data/modules/mruby/test/t/argumenterror.rb +3 -3
  223. data/modules/mruby/test/t/array.rb +55 -55
  224. data/modules/mruby/test/t/basicobject.rb +1 -1
  225. data/modules/mruby/test/t/bs_block.rb +12 -12
  226. data/modules/mruby/test/t/class.rb +21 -21
  227. data/modules/mruby/test/t/enumerable.rb +18 -18
  228. data/modules/mruby/test/t/exception.rb +20 -20
  229. data/modules/mruby/test/t/false.rb +3 -3
  230. data/modules/mruby/test/t/float.rb +40 -40
  231. data/modules/mruby/test/t/gc.rb +10 -10
  232. data/modules/mruby/test/t/hash.rb +41 -41
  233. data/modules/mruby/test/t/indexerror.rb +2 -2
  234. data/modules/mruby/test/t/integer.rb +41 -41
  235. data/modules/mruby/test/t/kernel.rb +33 -33
  236. data/modules/mruby/test/t/literals.rb +82 -82
  237. data/modules/mruby/test/t/localjumperror.rb +1 -1
  238. data/modules/mruby/test/t/module.rb +170 -31
  239. data/modules/mruby/test/t/nameerror.rb +5 -5
  240. data/modules/mruby/test/t/nil.rb +2 -2
  241. data/modules/mruby/test/t/nomethoderror.rb +1 -1
  242. data/modules/mruby/test/t/numeric.rb +5 -5
  243. data/modules/mruby/test/t/object.rb +2 -2
  244. data/modules/mruby/test/t/proc.rb +8 -8
  245. data/modules/mruby/test/t/range.rb +9 -9
  246. data/modules/mruby/test/t/rangeerror.rb +2 -2
  247. data/modules/mruby/test/t/runtimeerror.rb +1 -1
  248. data/modules/mruby/test/t/standarderror.rb +2 -2
  249. data/modules/mruby/test/t/string.rb +100 -100
  250. data/modules/mruby/test/t/symbol.rb +5 -5
  251. data/modules/mruby/test/t/syntax.rb +15 -6
  252. data/modules/mruby/test/t/true.rb +3 -3
  253. data/modules/mruby/test/t/typeerror.rb +2 -2
  254. data/modules/mruby/tools/mrbc/mrbc.c +10 -4
  255. data/modules/mruby/travis_config.rb +1 -0
  256. data/scripts/gen_gems_config.rb +5 -1
  257. metadata +19 -4
  258. data/modules/emscripten/tools/test-js-optimizer-asm-outline-output.js +0 -570
@@ -325,7 +325,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
325
325
 
326
326
  _LIBCPP_BEGIN_NAMESPACE_STD
327
327
 
328
- template <class _Key, class _Tp, class _Hash, bool = is_empty<_Hash>::value
328
+ template <class _Key, class _Cp, class _Hash, bool = is_empty<_Hash>::value
329
329
  #if __has_feature(is_final)
330
330
  && !__is_final(_Hash)
331
331
  #endif
@@ -333,8 +333,6 @@ template <class _Key, class _Tp, class _Hash, bool = is_empty<_Hash>::value
333
333
  class __unordered_map_hasher
334
334
  : private _Hash
335
335
  {
336
- typedef pair<typename remove_const<_Key>::type, _Tp> _Pp;
337
- typedef pair<const _Key, _Tp> _Cp;
338
336
  public:
339
337
  _LIBCPP_INLINE_VISIBILITY
340
338
  __unordered_map_hasher()
@@ -347,23 +345,18 @@ public:
347
345
  _LIBCPP_INLINE_VISIBILITY
348
346
  const _Hash& hash_function() const _NOEXCEPT {return *this;}
349
347
  _LIBCPP_INLINE_VISIBILITY
350
- size_t operator()(const _Pp& __x) const
351
- {return static_cast<const _Hash&>(*this)(__x.first);}
352
- _LIBCPP_INLINE_VISIBILITY
353
348
  size_t operator()(const _Cp& __x) const
354
- {return static_cast<const _Hash&>(*this)(__x.first);}
349
+ {return static_cast<const _Hash&>(*this)(__x.__cc.first);}
355
350
  _LIBCPP_INLINE_VISIBILITY
356
351
  size_t operator()(const _Key& __x) const
357
352
  {return static_cast<const _Hash&>(*this)(__x);}
358
353
  };
359
354
 
360
- template <class _Key, class _Tp, class _Hash>
361
- class __unordered_map_hasher<_Key, _Tp, _Hash, false>
355
+ template <class _Key, class _Cp, class _Hash>
356
+ class __unordered_map_hasher<_Key, _Cp, _Hash, false>
362
357
  {
363
358
  _Hash __hash_;
364
359
 
365
- typedef pair<typename remove_const<_Key>::type, _Tp> _Pp;
366
- typedef pair<const _Key, _Tp> _Cp;
367
360
  public:
368
361
  _LIBCPP_INLINE_VISIBILITY
369
362
  __unordered_map_hasher()
@@ -376,17 +369,14 @@ public:
376
369
  _LIBCPP_INLINE_VISIBILITY
377
370
  const _Hash& hash_function() const _NOEXCEPT {return __hash_;}
378
371
  _LIBCPP_INLINE_VISIBILITY
379
- size_t operator()(const _Pp& __x) const
380
- {return __hash_(__x.first);}
381
- _LIBCPP_INLINE_VISIBILITY
382
372
  size_t operator()(const _Cp& __x) const
383
- {return __hash_(__x.first);}
373
+ {return __hash_(__x.__cc.first);}
384
374
  _LIBCPP_INLINE_VISIBILITY
385
375
  size_t operator()(const _Key& __x) const
386
376
  {return __hash_(__x);}
387
377
  };
388
378
 
389
- template <class _Key, class _Tp, class _Pred, bool = is_empty<_Pred>::value
379
+ template <class _Key, class _Cp, class _Pred, bool = is_empty<_Pred>::value
390
380
  #if __has_feature(is_final)
391
381
  && !__is_final(_Pred)
392
382
  #endif
@@ -394,8 +384,6 @@ template <class _Key, class _Tp, class _Pred, bool = is_empty<_Pred>::value
394
384
  class __unordered_map_equal
395
385
  : private _Pred
396
386
  {
397
- typedef pair<typename remove_const<_Key>::type, _Tp> _Pp;
398
- typedef pair<const _Key, _Tp> _Cp;
399
387
  public:
400
388
  _LIBCPP_INLINE_VISIBILITY
401
389
  __unordered_map_equal()
@@ -408,41 +396,21 @@ public:
408
396
  _LIBCPP_INLINE_VISIBILITY
409
397
  const _Pred& key_eq() const _NOEXCEPT {return *this;}
410
398
  _LIBCPP_INLINE_VISIBILITY
411
- bool operator()(const _Pp& __x, const _Pp& __y) const
412
- {return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
413
- _LIBCPP_INLINE_VISIBILITY
414
- bool operator()(const _Pp& __x, const _Cp& __y) const
415
- {return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
416
- _LIBCPP_INLINE_VISIBILITY
417
- bool operator()(const _Pp& __x, const _Key& __y) const
418
- {return static_cast<const _Pred&>(*this)(__x.first, __y);}
419
- _LIBCPP_INLINE_VISIBILITY
420
- bool operator()(const _Cp& __x, const _Pp& __y) const
421
- {return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
422
- _LIBCPP_INLINE_VISIBILITY
423
399
  bool operator()(const _Cp& __x, const _Cp& __y) const
424
- {return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
400
+ {return static_cast<const _Pred&>(*this)(__x.__cc.first, __y.__cc.first);}
425
401
  _LIBCPP_INLINE_VISIBILITY
426
402
  bool operator()(const _Cp& __x, const _Key& __y) const
427
- {return static_cast<const _Pred&>(*this)(__x.first, __y);}
428
- _LIBCPP_INLINE_VISIBILITY
429
- bool operator()(const _Key& __x, const _Pp& __y) const
430
- {return static_cast<const _Pred&>(*this)(__x, __y.first);}
403
+ {return static_cast<const _Pred&>(*this)(__x.__cc.first, __y);}
431
404
  _LIBCPP_INLINE_VISIBILITY
432
405
  bool operator()(const _Key& __x, const _Cp& __y) const
433
- {return static_cast<const _Pred&>(*this)(__x, __y.first);}
434
- _LIBCPP_INLINE_VISIBILITY
435
- bool operator()(const _Key& __x, const _Key& __y) const
436
- {return static_cast<const _Pred&>(*this)(__x, __y);}
406
+ {return static_cast<const _Pred&>(*this)(__x, __y.__cc.first);}
437
407
  };
438
408
 
439
- template <class _Key, class _Tp, class _Pred>
440
- class __unordered_map_equal<_Key, _Tp, _Pred, false>
409
+ template <class _Key, class _Cp, class _Pred>
410
+ class __unordered_map_equal<_Key, _Cp, _Pred, false>
441
411
  {
442
412
  _Pred __pred_;
443
413
 
444
- typedef pair<typename remove_const<_Key>::type, _Tp> _Pp;
445
- typedef pair<const _Key, _Tp> _Cp;
446
414
  public:
447
415
  _LIBCPP_INLINE_VISIBILITY
448
416
  __unordered_map_equal()
@@ -455,32 +423,14 @@ public:
455
423
  _LIBCPP_INLINE_VISIBILITY
456
424
  const _Pred& key_eq() const _NOEXCEPT {return __pred_;}
457
425
  _LIBCPP_INLINE_VISIBILITY
458
- bool operator()(const _Pp& __x, const _Pp& __y) const
459
- {return __pred_(__x.first, __y.first);}
460
- _LIBCPP_INLINE_VISIBILITY
461
- bool operator()(const _Pp& __x, const _Cp& __y) const
462
- {return __pred_(__x.first, __y.first);}
463
- _LIBCPP_INLINE_VISIBILITY
464
- bool operator()(const _Pp& __x, const _Key& __y) const
465
- {return __pred_(__x.first, __y);}
466
- _LIBCPP_INLINE_VISIBILITY
467
- bool operator()(const _Cp& __x, const _Pp& __y) const
468
- {return __pred_(__x.first, __y.first);}
469
- _LIBCPP_INLINE_VISIBILITY
470
426
  bool operator()(const _Cp& __x, const _Cp& __y) const
471
- {return __pred_(__x.first, __y.first);}
427
+ {return __pred_(__x.__cc.first, __y.__cc.first);}
472
428
  _LIBCPP_INLINE_VISIBILITY
473
429
  bool operator()(const _Cp& __x, const _Key& __y) const
474
- {return __pred_(__x.first, __y);}
475
- _LIBCPP_INLINE_VISIBILITY
476
- bool operator()(const _Key& __x, const _Pp& __y) const
477
- {return __pred_(__x, __y.first);}
430
+ {return __pred_(__x.__cc.first, __y);}
478
431
  _LIBCPP_INLINE_VISIBILITY
479
432
  bool operator()(const _Key& __x, const _Cp& __y) const
480
- {return __pred_(__x, __y.first);}
481
- _LIBCPP_INLINE_VISIBILITY
482
- bool operator()(const _Key& __x, const _Key& __y) const
483
- {return __pred_(__x, __y);}
433
+ {return __pred_(__x, __y.__cc.first);}
484
434
  };
485
435
 
486
436
  template <class _Alloc>
@@ -492,8 +442,8 @@ class __hash_map_node_destructor
492
442
  public:
493
443
  typedef typename __alloc_traits::pointer pointer;
494
444
  private:
495
- typedef typename value_type::first_type first_type;
496
- typedef typename value_type::second_type second_type;
445
+ typedef typename value_type::value_type::first_type first_type;
446
+ typedef typename value_type::value_type::second_type second_type;
497
447
 
498
448
  allocator_type& __na_;
499
449
 
@@ -535,9 +485,9 @@ public:
535
485
  void operator()(pointer __p) _NOEXCEPT
536
486
  {
537
487
  if (__second_constructed)
538
- __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.second));
488
+ __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.second));
539
489
  if (__first_constructed)
540
- __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.first));
490
+ __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.first));
541
491
  if (__p)
542
492
  __alloc_traits::deallocate(__na_, __p, 1);
543
493
  }
@@ -549,8 +499,8 @@ class _LIBCPP_TYPE_VIS __hash_map_iterator
549
499
  _HashIterator __i_;
550
500
 
551
501
  typedef pointer_traits<typename _HashIterator::pointer> __pointer_traits;
552
- typedef const typename _HashIterator::value_type::first_type key_type;
553
- typedef typename _HashIterator::value_type::second_type mapped_type;
502
+ typedef const typename _HashIterator::value_type::value_type::first_type key_type;
503
+ typedef typename _HashIterator::value_type::value_type::second_type mapped_type;
554
504
  public:
555
505
  typedef forward_iterator_tag iterator_category;
556
506
  typedef pair<key_type, mapped_type> value_type;
@@ -571,9 +521,9 @@ public:
571
521
  __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
572
522
 
573
523
  _LIBCPP_INLINE_VISIBILITY
574
- reference operator*() const {return *operator->();}
524
+ reference operator*() const {return __i_->__cc;}
575
525
  _LIBCPP_INLINE_VISIBILITY
576
- pointer operator->() const {return (pointer)__i_.operator->();}
526
+ pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
577
527
 
578
528
  _LIBCPP_INLINE_VISIBILITY
579
529
  __hash_map_iterator& operator++() {++__i_; return *this;}
@@ -605,8 +555,8 @@ class _LIBCPP_TYPE_VIS __hash_map_const_iterator
605
555
  _HashIterator __i_;
606
556
 
607
557
  typedef pointer_traits<typename _HashIterator::pointer> __pointer_traits;
608
- typedef const typename _HashIterator::value_type::first_type key_type;
609
- typedef typename _HashIterator::value_type::second_type mapped_type;
558
+ typedef const typename _HashIterator::value_type::value_type::first_type key_type;
559
+ typedef typename _HashIterator::value_type::value_type::second_type mapped_type;
610
560
  public:
611
561
  typedef forward_iterator_tag iterator_category;
612
562
  typedef pair<key_type, mapped_type> value_type;
@@ -632,9 +582,9 @@ public:
632
582
  : __i_(__i.__i_) {}
633
583
 
634
584
  _LIBCPP_INLINE_VISIBILITY
635
- reference operator*() const {return *operator->();}
585
+ reference operator*() const {return __i_->__cc;}
636
586
  _LIBCPP_INLINE_VISIBILITY
637
- pointer operator->() const {return (pointer)__i_.operator->();}
587
+ pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
638
588
 
639
589
  _LIBCPP_INLINE_VISIBILITY
640
590
  __hash_map_const_iterator& operator++() {++__i_; return *this;}
@@ -671,13 +621,58 @@ public:
671
621
  typedef _Pred key_equal;
672
622
  typedef _Alloc allocator_type;
673
623
  typedef pair<const key_type, mapped_type> value_type;
624
+ typedef pair<key_type, mapped_type> __nc_value_type;
674
625
  typedef value_type& reference;
675
626
  typedef const value_type& const_reference;
627
+ static_assert((is_same<value_type, typename allocator_type::value_type>::value),
628
+ "Invalid allocator::value_type");
676
629
 
677
630
  private:
678
- typedef pair<key_type, mapped_type> __value_type;
679
- typedef __unordered_map_hasher<key_type, mapped_type, hasher> __hasher;
680
- typedef __unordered_map_equal<key_type, mapped_type, key_equal> __key_equal;
631
+ #if __cplusplus >= 201103L
632
+ union __value_type
633
+ {
634
+ typedef typename unordered_map::value_type value_type;
635
+ typedef typename unordered_map::__nc_value_type __nc_value_type;
636
+ value_type __cc;
637
+ __nc_value_type __nc;
638
+
639
+ template <class ..._Args>
640
+ __value_type(_Args&& ...__args)
641
+ : __cc(std::forward<_Args>(__args)...) {}
642
+
643
+ __value_type(const __value_type& __v)
644
+ : __cc(std::move(__v.__cc)) {}
645
+
646
+ __value_type(__value_type&& __v)
647
+ : __nc(std::move(__v.__nc)) {}
648
+
649
+ __value_type& operator=(const __value_type& __v)
650
+ {__nc = __v.__cc; return *this;}
651
+
652
+ __value_type& operator=(__value_type&& __v)
653
+ {__nc = std::move(__v.__nc); return *this;}
654
+
655
+ ~__value_type() {__cc.~value_type();}
656
+ };
657
+ #else
658
+ struct __value_type
659
+ {
660
+ typedef typename unordered_map::value_type value_type;
661
+ value_type __cc;
662
+
663
+ __value_type() {}
664
+
665
+ template <class _A0>
666
+ __value_type(const _A0& __a0)
667
+ : __cc(__a0) {}
668
+
669
+ template <class _A0, class _A1>
670
+ __value_type(const _A0& __a0, const _A1& __a1)
671
+ : __cc(__a0, __a1) {}
672
+ };
673
+ #endif
674
+ typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;
675
+ typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
681
676
  typedef typename allocator_traits<allocator_type>::template
682
677
  #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
683
678
  rebind_alloc<__value_type>
@@ -713,7 +708,11 @@ public:
713
708
  _LIBCPP_INLINE_VISIBILITY
714
709
  unordered_map()
715
710
  _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
716
- {} // = default;
711
+ {
712
+ #if _LIBCPP_DEBUG_LEVEL >= 2
713
+ __get_db()->__insert_c(this);
714
+ #endif
715
+ }
717
716
  explicit unordered_map(size_type __n, const hasher& __hf = hasher(),
718
717
  const key_equal& __eql = key_equal());
719
718
  unordered_map(size_type __n, const hasher& __hf,
@@ -750,7 +749,16 @@ public:
750
749
  _LIBCPP_INLINE_VISIBILITY
751
750
  unordered_map& operator=(const unordered_map& __u)
752
751
  {
752
+ #if __cplusplus >= 201103L
753
753
  __table_ = __u.__table_;
754
+ #else
755
+ __table_.clear();
756
+ __table_.hash_function() = __u.__table_.hash_function();
757
+ __table_.key_eq() = __u.__table_.key_eq();
758
+ __table_.max_load_factor() = __u.__table_.max_load_factor();
759
+ __table_.__copy_assign_alloc(__u.__table_);
760
+ insert(__u.begin(), __u.end());
761
+ #endif
754
762
  return *this;
755
763
  }
756
764
  #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -793,8 +801,18 @@ public:
793
801
 
794
802
  template <class... _Args>
795
803
  _LIBCPP_INLINE_VISIBILITY
804
+ #if _LIBCPP_DEBUG_LEVEL >= 2
805
+ iterator emplace_hint(const_iterator __p, _Args&&... __args)
806
+ {
807
+ _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
808
+ "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"
809
+ " referring to this unordered_map");
810
+ return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
811
+ }
812
+ #else
796
813
  iterator emplace_hint(const_iterator, _Args&&... __args)
797
814
  {return emplace(_VSTD::forward<_Args>(__args)...).first;}
815
+ #endif
798
816
  #endif // _LIBCPP_HAS_NO_VARIADICS
799
817
  #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
800
818
  _LIBCPP_INLINE_VISIBILITY
@@ -808,14 +826,34 @@ public:
808
826
  {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));}
809
827
  #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
810
828
  _LIBCPP_INLINE_VISIBILITY
829
+ #if _LIBCPP_DEBUG_LEVEL >= 2
830
+ iterator insert(const_iterator __p, const value_type& __x)
831
+ {
832
+ _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
833
+ "unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
834
+ " referring to this unordered_map");
835
+ return insert(__x).first;
836
+ }
837
+ #else
811
838
  iterator insert(const_iterator, const value_type& __x)
812
839
  {return insert(__x).first;}
840
+ #endif
813
841
  #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
814
842
  template <class _Pp,
815
843
  class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
816
844
  _LIBCPP_INLINE_VISIBILITY
845
+ #if _LIBCPP_DEBUG_LEVEL >= 2
846
+ iterator insert(const_iterator __p, _Pp&& __x)
847
+ {
848
+ _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
849
+ "unordered_map::insert(const_iterator, value_type&&) called with an iterator not"
850
+ " referring to this unordered_map");
851
+ return insert(_VSTD::forward<_Pp>(__x)).first;
852
+ }
853
+ #else
817
854
  iterator insert(const_iterator, _Pp&& __x)
818
855
  {return insert(_VSTD::forward<_Pp>(__x)).first;}
856
+ #endif
819
857
  #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
820
858
  template <class _InputIterator>
821
859
  void insert(_InputIterator __first, _InputIterator __last);
@@ -903,30 +941,32 @@ public:
903
941
  _LIBCPP_INLINE_VISIBILITY
904
942
  void reserve(size_type __n) {__table_.reserve(__n);}
905
943
 
944
+ #if _LIBCPP_DEBUG_LEVEL >= 2
945
+
946
+ bool __dereferenceable(const const_iterator* __i) const
947
+ {return __table_.__dereferenceable(&__i->__i_);}
948
+ bool __decrementable(const const_iterator* __i) const
949
+ {return __table_.__decrementable(&__i->__i_);}
950
+ bool __addable(const const_iterator* __i, ptrdiff_t __n) const
951
+ {return __table_.__addable(&__i->__i_, __n);}
952
+ bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
953
+ {return __table_.__addable(&__i->__i_, __n);}
954
+
955
+ #endif // _LIBCPP_DEBUG_LEVEL >= 2
956
+
906
957
  private:
907
958
  #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
908
959
  __node_holder __construct_node();
909
960
  template <class _A0>
910
- typename enable_if
911
- <
912
- is_constructible<value_type, _A0>::value,
913
- __node_holder
914
- >::type
915
- __construct_node(_A0&& __a0);
916
- template <class _A0>
917
- typename enable_if
918
- <
919
- is_constructible<key_type, _A0>::value,
920
- __node_holder
921
- >::type
961
+ __node_holder
922
962
  __construct_node(_A0&& __a0);
963
+ __node_holder __construct_node_with_key(key_type&& __k);
923
964
  #ifndef _LIBCPP_HAS_NO_VARIADICS
924
965
  template <class _A0, class _A1, class ..._Args>
925
966
  __node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
926
967
  #endif // _LIBCPP_HAS_NO_VARIADICS
927
- #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
928
- __node_holder __construct_node(const key_type& __k);
929
- #endif
968
+ #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
969
+ __node_holder __construct_node_with_key(const key_type& __k);
930
970
  };
931
971
 
932
972
  template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -934,6 +974,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
934
974
  size_type __n, const hasher& __hf, const key_equal& __eql)
935
975
  : __table_(__hf, __eql)
936
976
  {
977
+ #if _LIBCPP_DEBUG_LEVEL >= 2
978
+ __get_db()->__insert_c(this);
979
+ #endif
937
980
  __table_.rehash(__n);
938
981
  }
939
982
 
@@ -943,6 +986,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
943
986
  const allocator_type& __a)
944
987
  : __table_(__hf, __eql, __a)
945
988
  {
989
+ #if _LIBCPP_DEBUG_LEVEL >= 2
990
+ __get_db()->__insert_c(this);
991
+ #endif
946
992
  __table_.rehash(__n);
947
993
  }
948
994
 
@@ -952,6 +998,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
952
998
  const allocator_type& __a)
953
999
  : __table_(__a)
954
1000
  {
1001
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1002
+ __get_db()->__insert_c(this);
1003
+ #endif
955
1004
  }
956
1005
 
957
1006
  template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -959,6 +1008,9 @@ template <class _InputIterator>
959
1008
  unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
960
1009
  _InputIterator __first, _InputIterator __last)
961
1010
  {
1011
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1012
+ __get_db()->__insert_c(this);
1013
+ #endif
962
1014
  insert(__first, __last);
963
1015
  }
964
1016
 
@@ -969,6 +1021,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
969
1021
  const hasher& __hf, const key_equal& __eql)
970
1022
  : __table_(__hf, __eql)
971
1023
  {
1024
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1025
+ __get_db()->__insert_c(this);
1026
+ #endif
972
1027
  __table_.rehash(__n);
973
1028
  insert(__first, __last);
974
1029
  }
@@ -980,6 +1035,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
980
1035
  const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
981
1036
  : __table_(__hf, __eql, __a)
982
1037
  {
1038
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1039
+ __get_db()->__insert_c(this);
1040
+ #endif
983
1041
  __table_.rehash(__n);
984
1042
  insert(__first, __last);
985
1043
  }
@@ -989,6 +1047,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
989
1047
  const unordered_map& __u)
990
1048
  : __table_(__u.__table_)
991
1049
  {
1050
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1051
+ __get_db()->__insert_c(this);
1052
+ #endif
992
1053
  __table_.rehash(__u.bucket_count());
993
1054
  insert(__u.begin(), __u.end());
994
1055
  }
@@ -998,6 +1059,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
998
1059
  const unordered_map& __u, const allocator_type& __a)
999
1060
  : __table_(__u.__table_, __a)
1000
1061
  {
1062
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1063
+ __get_db()->__insert_c(this);
1064
+ #endif
1001
1065
  __table_.rehash(__u.bucket_count());
1002
1066
  insert(__u.begin(), __u.end());
1003
1067
  }
@@ -1011,6 +1075,10 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1011
1075
  _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
1012
1076
  : __table_(_VSTD::move(__u.__table_))
1013
1077
  {
1078
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1079
+ __get_db()->__insert_c(this);
1080
+ __get_db()->swap(this, &__u);
1081
+ #endif
1014
1082
  }
1015
1083
 
1016
1084
  template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -1018,6 +1086,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1018
1086
  unordered_map&& __u, const allocator_type& __a)
1019
1087
  : __table_(_VSTD::move(__u.__table_), __a)
1020
1088
  {
1089
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1090
+ __get_db()->__insert_c(this);
1091
+ #endif
1021
1092
  if (__a != __u.get_allocator())
1022
1093
  {
1023
1094
  iterator __i = __u.begin();
@@ -1026,6 +1097,10 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1026
1097
  _VSTD::move(__u.__table_.remove((__i++).__i_)->__value_)
1027
1098
  );
1028
1099
  }
1100
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1101
+ else
1102
+ __get_db()->swap(this, &__u);
1103
+ #endif
1029
1104
  }
1030
1105
 
1031
1106
  #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -1036,6 +1111,9 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1036
1111
  unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1037
1112
  initializer_list<value_type> __il)
1038
1113
  {
1114
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1115
+ __get_db()->__insert_c(this);
1116
+ #endif
1039
1117
  insert(__il.begin(), __il.end());
1040
1118
  }
1041
1119
 
@@ -1045,6 +1123,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1045
1123
  const key_equal& __eql)
1046
1124
  : __table_(__hf, __eql)
1047
1125
  {
1126
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1127
+ __get_db()->__insert_c(this);
1128
+ #endif
1048
1129
  __table_.rehash(__n);
1049
1130
  insert(__il.begin(), __il.end());
1050
1131
  }
@@ -1055,6 +1136,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1055
1136
  const key_equal& __eql, const allocator_type& __a)
1056
1137
  : __table_(__hf, __eql, __a)
1057
1138
  {
1139
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1140
+ __get_db()->__insert_c(this);
1141
+ #endif
1058
1142
  __table_.rehash(__n);
1059
1143
  insert(__il.begin(), __il.end());
1060
1144
  }
@@ -1105,11 +1189,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node()
1105
1189
 
1106
1190
  template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1107
1191
  template <class _A0>
1108
- typename enable_if
1109
- <
1110
- is_constructible<pair<const _Key, _Tp>, _A0>::value,
1111
- typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1112
- >::type
1192
+ typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1113
1193
  unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
1114
1194
  {
1115
1195
  __node_allocator& __na = __table_.__node_alloc();
@@ -1122,22 +1202,16 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
1122
1202
  }
1123
1203
 
1124
1204
  template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1125
- template <class _A0>
1126
- typename enable_if
1127
- <
1128
- is_constructible<_Key, _A0>::value,
1129
- typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1130
- >::type
1131
- unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
1205
+ typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1206
+ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(key_type&& __k)
1132
1207
  {
1133
1208
  __node_allocator& __na = __table_.__node_alloc();
1134
1209
  __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1135
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.first),
1136
- _VSTD::forward<_A0>(__a0));
1210
+ __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::move(__k));
1137
1211
  __h.get_deleter().__first_constructed = true;
1138
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));
1212
+ __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
1139
1213
  __h.get_deleter().__second_constructed = true;
1140
- return __h;
1214
+ return _VSTD::move(__h);
1141
1215
  }
1142
1216
 
1143
1217
  #ifndef _LIBCPP_HAS_NO_VARIADICS
@@ -1172,23 +1246,21 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
1172
1246
  }
1173
1247
 
1174
1248
  #endif // _LIBCPP_HAS_NO_VARIADICS
1175
- #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1249
+ #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1176
1250
 
1177
1251
  template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1178
1252
  typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1179
- unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k)
1253
+ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k)
1180
1254
  {
1181
1255
  __node_allocator& __na = __table_.__node_alloc();
1182
1256
  __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1183
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.first), __k);
1257
+ __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), __k);
1184
1258
  __h.get_deleter().__first_constructed = true;
1185
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));
1259
+ __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
1186
1260
  __h.get_deleter().__second_constructed = true;
1187
1261
  return _VSTD::move(__h);
1188
1262
  }
1189
1263
 
1190
- #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1191
-
1192
1264
  template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1193
1265
  template <class _InputIterator>
1194
1266
  inline _LIBCPP_INLINE_VISIBILITY
@@ -1207,7 +1279,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
1207
1279
  iterator __i = find(__k);
1208
1280
  if (__i != end())
1209
1281
  return __i->second;
1210
- __node_holder __h = __construct_node(__k);
1282
+ __node_holder __h = __construct_node_with_key(__k);
1211
1283
  pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
1212
1284
  __h.release();
1213
1285
  return __r.first->second;
@@ -1222,7 +1294,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)
1222
1294
  iterator __i = find(__k);
1223
1295
  if (__i != end())
1224
1296
  return __i->second;
1225
- __node_holder __h = __construct_node(_VSTD::move(__k));
1297
+ __node_holder __h = __construct_node_with_key(_VSTD::move(__k));
1226
1298
  pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
1227
1299
  __h.release();
1228
1300
  return __r.first->second;
@@ -1304,13 +1376,58 @@ public:
1304
1376
  typedef _Pred key_equal;
1305
1377
  typedef _Alloc allocator_type;
1306
1378
  typedef pair<const key_type, mapped_type> value_type;
1379
+ typedef pair<key_type, mapped_type> __nc_value_type;
1307
1380
  typedef value_type& reference;
1308
1381
  typedef const value_type& const_reference;
1382
+ static_assert((is_same<value_type, typename allocator_type::value_type>::value),
1383
+ "Invalid allocator::value_type");
1309
1384
 
1310
1385
  private:
1311
- typedef pair<key_type, mapped_type> __value_type;
1312
- typedef __unordered_map_hasher<key_type, mapped_type, hasher> __hasher;
1313
- typedef __unordered_map_equal<key_type, mapped_type, key_equal> __key_equal;
1386
+ #if __cplusplus >= 201103L
1387
+ union __value_type
1388
+ {
1389
+ typedef typename unordered_multimap::value_type value_type;
1390
+ typedef typename unordered_multimap::__nc_value_type __nc_value_type;
1391
+ value_type __cc;
1392
+ __nc_value_type __nc;
1393
+
1394
+ template <class ..._Args>
1395
+ __value_type(_Args&& ...__args)
1396
+ : __cc(std::forward<_Args>(__args)...) {}
1397
+
1398
+ __value_type(const __value_type& __v)
1399
+ : __cc(std::move(__v.__cc)) {}
1400
+
1401
+ __value_type(__value_type&& __v)
1402
+ : __nc(std::move(__v.__nc)) {}
1403
+
1404
+ __value_type& operator=(const __value_type& __v)
1405
+ {__nc = __v.__cc; return *this;}
1406
+
1407
+ __value_type& operator=(__value_type&& __v)
1408
+ {__nc = std::move(__v.__nc); return *this;}
1409
+
1410
+ ~__value_type() {__cc.~value_type();}
1411
+ };
1412
+ #else
1413
+ struct __value_type
1414
+ {
1415
+ typedef typename unordered_multimap::value_type value_type;
1416
+ value_type __cc;
1417
+
1418
+ __value_type() {}
1419
+
1420
+ template <class _A0>
1421
+ __value_type(const _A0& __a0)
1422
+ : __cc(__a0) {}
1423
+
1424
+ template <class _A0, class _A1>
1425
+ __value_type(const _A0& __a0, const _A1& __a1)
1426
+ : __cc(__a0, __a1) {}
1427
+ };
1428
+ #endif
1429
+ typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;
1430
+ typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
1314
1431
  typedef typename allocator_traits<allocator_type>::template
1315
1432
  #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
1316
1433
  rebind_alloc<__value_type>
@@ -1344,7 +1461,11 @@ public:
1344
1461
  _LIBCPP_INLINE_VISIBILITY
1345
1462
  unordered_multimap()
1346
1463
  _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
1347
- {} // = default;
1464
+ {
1465
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1466
+ __get_db()->__insert_c(this);
1467
+ #endif
1468
+ }
1348
1469
  explicit unordered_multimap(size_type __n, const hasher& __hf = hasher(),
1349
1470
  const key_equal& __eql = key_equal());
1350
1471
  unordered_multimap(size_type __n, const hasher& __hf,
@@ -1382,7 +1503,16 @@ public:
1382
1503
  _LIBCPP_INLINE_VISIBILITY
1383
1504
  unordered_multimap& operator=(const unordered_multimap& __u)
1384
1505
  {
1506
+ #if __cplusplus >= 201103L
1385
1507
  __table_ = __u.__table_;
1508
+ #else
1509
+ __table_.clear();
1510
+ __table_.hash_function() = __u.__table_.hash_function();
1511
+ __table_.key_eq() = __u.__table_.key_eq();
1512
+ __table_.max_load_factor() = __u.__table_.max_load_factor();
1513
+ __table_.__copy_assign_alloc(__u.__table_);
1514
+ insert(__u.begin(), __u.end());
1515
+ #endif
1386
1516
  return *this;
1387
1517
  }
1388
1518
  #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -1525,22 +1655,24 @@ public:
1525
1655
  _LIBCPP_INLINE_VISIBILITY
1526
1656
  void reserve(size_type __n) {__table_.reserve(__n);}
1527
1657
 
1658
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1659
+
1660
+ bool __dereferenceable(const const_iterator* __i) const
1661
+ {return __table_.__dereferenceable(&__i->__i_);}
1662
+ bool __decrementable(const const_iterator* __i) const
1663
+ {return __table_.__decrementable(&__i->__i_);}
1664
+ bool __addable(const const_iterator* __i, ptrdiff_t __n) const
1665
+ {return __table_.__addable(&__i->__i_, __n);}
1666
+ bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
1667
+ {return __table_.__addable(&__i->__i_, __n);}
1668
+
1669
+ #endif // _LIBCPP_DEBUG_LEVEL >= 2
1670
+
1528
1671
  private:
1529
1672
  #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1530
1673
  __node_holder __construct_node();
1531
1674
  template <class _A0>
1532
- typename enable_if
1533
- <
1534
- is_constructible<value_type, _A0>::value,
1535
- __node_holder
1536
- >::type
1537
- __construct_node(_A0&& __a0);
1538
- template <class _A0>
1539
- typename enable_if
1540
- <
1541
- is_constructible<key_type, _A0>::value,
1542
- __node_holder
1543
- >::type
1675
+ __node_holder
1544
1676
  __construct_node(_A0&& __a0);
1545
1677
  #ifndef _LIBCPP_HAS_NO_VARIADICS
1546
1678
  template <class _A0, class _A1, class ..._Args>
@@ -1554,6 +1686,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1554
1686
  size_type __n, const hasher& __hf, const key_equal& __eql)
1555
1687
  : __table_(__hf, __eql)
1556
1688
  {
1689
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1690
+ __get_db()->__insert_c(this);
1691
+ #endif
1557
1692
  __table_.rehash(__n);
1558
1693
  }
1559
1694
 
@@ -1563,6 +1698,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1563
1698
  const allocator_type& __a)
1564
1699
  : __table_(__hf, __eql, __a)
1565
1700
  {
1701
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1702
+ __get_db()->__insert_c(this);
1703
+ #endif
1566
1704
  __table_.rehash(__n);
1567
1705
  }
1568
1706
 
@@ -1571,6 +1709,9 @@ template <class _InputIterator>
1571
1709
  unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1572
1710
  _InputIterator __first, _InputIterator __last)
1573
1711
  {
1712
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1713
+ __get_db()->__insert_c(this);
1714
+ #endif
1574
1715
  insert(__first, __last);
1575
1716
  }
1576
1717
 
@@ -1581,6 +1722,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1581
1722
  const hasher& __hf, const key_equal& __eql)
1582
1723
  : __table_(__hf, __eql)
1583
1724
  {
1725
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1726
+ __get_db()->__insert_c(this);
1727
+ #endif
1584
1728
  __table_.rehash(__n);
1585
1729
  insert(__first, __last);
1586
1730
  }
@@ -1592,6 +1736,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1592
1736
  const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1593
1737
  : __table_(__hf, __eql, __a)
1594
1738
  {
1739
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1740
+ __get_db()->__insert_c(this);
1741
+ #endif
1595
1742
  __table_.rehash(__n);
1596
1743
  insert(__first, __last);
1597
1744
  }
@@ -1602,6 +1749,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1602
1749
  const allocator_type& __a)
1603
1750
  : __table_(__a)
1604
1751
  {
1752
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1753
+ __get_db()->__insert_c(this);
1754
+ #endif
1605
1755
  }
1606
1756
 
1607
1757
  template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -1609,6 +1759,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1609
1759
  const unordered_multimap& __u)
1610
1760
  : __table_(__u.__table_)
1611
1761
  {
1762
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1763
+ __get_db()->__insert_c(this);
1764
+ #endif
1612
1765
  __table_.rehash(__u.bucket_count());
1613
1766
  insert(__u.begin(), __u.end());
1614
1767
  }
@@ -1618,6 +1771,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1618
1771
  const unordered_multimap& __u, const allocator_type& __a)
1619
1772
  : __table_(__u.__table_, __a)
1620
1773
  {
1774
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1775
+ __get_db()->__insert_c(this);
1776
+ #endif
1621
1777
  __table_.rehash(__u.bucket_count());
1622
1778
  insert(__u.begin(), __u.end());
1623
1779
  }
@@ -1631,6 +1787,10 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1631
1787
  _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
1632
1788
  : __table_(_VSTD::move(__u.__table_))
1633
1789
  {
1790
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1791
+ __get_db()->__insert_c(this);
1792
+ __get_db()->swap(this, &__u);
1793
+ #endif
1634
1794
  }
1635
1795
 
1636
1796
  template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -1638,16 +1798,23 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1638
1798
  unordered_multimap&& __u, const allocator_type& __a)
1639
1799
  : __table_(_VSTD::move(__u.__table_), __a)
1640
1800
  {
1801
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1802
+ __get_db()->__insert_c(this);
1803
+ #endif
1641
1804
  if (__a != __u.get_allocator())
1642
1805
  {
1643
1806
  iterator __i = __u.begin();
1644
1807
  while (__u.size() != 0)
1645
- {
1808
+ {
1646
1809
  __table_.__insert_multi(
1647
1810
  _VSTD::move(__u.__table_.remove((__i++).__i_)->__value_)
1648
1811
  );
1649
- }
1812
+ }
1650
1813
  }
1814
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1815
+ else
1816
+ __get_db()->swap(this, &__u);
1817
+ #endif
1651
1818
  }
1652
1819
 
1653
1820
  #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -1658,6 +1825,9 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1658
1825
  unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1659
1826
  initializer_list<value_type> __il)
1660
1827
  {
1828
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1829
+ __get_db()->__insert_c(this);
1830
+ #endif
1661
1831
  insert(__il.begin(), __il.end());
1662
1832
  }
1663
1833
 
@@ -1667,6 +1837,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1667
1837
  const key_equal& __eql)
1668
1838
  : __table_(__hf, __eql)
1669
1839
  {
1840
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1841
+ __get_db()->__insert_c(this);
1842
+ #endif
1670
1843
  __table_.rehash(__n);
1671
1844
  insert(__il.begin(), __il.end());
1672
1845
  }
@@ -1677,6 +1850,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1677
1850
  const key_equal& __eql, const allocator_type& __a)
1678
1851
  : __table_(__hf, __eql, __a)
1679
1852
  {
1853
+ #if _LIBCPP_DEBUG_LEVEL >= 2
1854
+ __get_db()->__insert_c(this);
1855
+ #endif
1680
1856
  __table_.rehash(__n);
1681
1857
  insert(__il.begin(), __il.end());
1682
1858
  }
@@ -1727,11 +1903,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node()
1727
1903
 
1728
1904
  template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1729
1905
  template <class _A0>
1730
- typename enable_if
1731
- <
1732
- is_constructible<pair<const _Key, _Tp>, _A0>::value,
1733
- typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1734
- >::type
1906
+ typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1735
1907
  unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
1736
1908
  {
1737
1909
  __node_allocator& __na = __table_.__node_alloc();
@@ -1743,25 +1915,6 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0
1743
1915
  return __h;
1744
1916
  }
1745
1917
 
1746
- template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1747
- template <class _A0>
1748
- typename enable_if
1749
- <
1750
- is_constructible<_Key, _A0>::value,
1751
- typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1752
- >::type
1753
- unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
1754
- {
1755
- __node_allocator& __na = __table_.__node_alloc();
1756
- __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1757
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.first),
1758
- _VSTD::forward<_A0>(__a0));
1759
- __h.get_deleter().__first_constructed = true;
1760
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));
1761
- __h.get_deleter().__second_constructed = true;
1762
- return __h;
1763
- }
1764
-
1765
1918
  #ifndef _LIBCPP_HAS_NO_VARIADICS
1766
1919
 
1767
1920
  template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>