passenger 4.0.20 → 4.0.21

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (496) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/.gitignore +1 -0
  5. data/.travis.yml +1 -1
  6. data/NEWS +15 -0
  7. data/README.md +5 -3
  8. data/Rakefile +1 -0
  9. data/bin/passenger-config +1 -5
  10. data/bin/passenger-install-apache2-module +53 -5
  11. data/bin/passenger-install-nginx-module +19 -6
  12. data/bin/passenger-memory-stats +3 -3
  13. data/build/agents.rb +11 -8
  14. data/build/apache2.rb +9 -5
  15. data/build/basics.rb +15 -21
  16. data/build/common_library.rb +16 -6
  17. data/build/cplusplus_support.rb +5 -5
  18. data/build/cxx_tests.rb +3 -3
  19. data/build/documentation.rb +1 -1
  20. data/build/misc.rb +4 -37
  21. data/build/node_tests.rb +29 -0
  22. data/build/oxt_tests.rb +1 -1
  23. data/build/packaging.rb +29 -10
  24. data/build/preprocessor.rb +2 -1
  25. data/build/test_basics.rb +15 -6
  26. data/debian.template/locations.ini.template +1 -0
  27. data/debian.template/passenger.install.template +1 -0
  28. data/dev/copy_boost_headers.rb +7 -3
  29. data/dev/run_travis.sh +32 -16
  30. data/doc/Users guide Apache.idmap.txt +22 -34
  31. data/doc/Users guide Apache.txt +20 -234
  32. data/doc/Users guide Nginx.idmap.txt +84 -66
  33. data/doc/Users guide Nginx.txt +50 -1
  34. data/doc/Users guide Standalone.idmap.txt +74 -0
  35. data/doc/Users guide Standalone.txt +22 -9
  36. data/doc/Users guide.txt +51 -0
  37. data/doc/users_guide_snippets/environment_variables.txt +0 -3
  38. data/doc/users_guide_snippets/installation.txt +337 -380
  39. data/doc/users_guide_snippets/installation/run_installer.txt +58 -0
  40. data/doc/users_guide_snippets/installation/verify_running_epilogue.txt +6 -0
  41. data/doc/users_guide_snippets/support_information.txt +2 -9
  42. data/doc/users_guide_snippets/troubleshooting/default.txt +112 -0
  43. data/doc/users_guide_snippets/troubleshooting/rails.txt +56 -0
  44. data/doc/users_guide_snippets/where_to_get_support.txt +9 -0
  45. data/ext/apache2/Bucket.h +1 -1
  46. data/ext/apache2/Configuration.hpp +0 -44
  47. data/ext/apache2/CreateDirConfig.cpp +1 -1
  48. data/ext/apache2/CreateDirConfig.cpp.erb +1 -1
  49. data/ext/apache2/Hooks.cpp +28 -21
  50. data/ext/apache2/MergeDirConfig.cpp +1 -0
  51. data/ext/apache2/MergeDirConfig.cpp.erb +1 -1
  52. data/ext/apache2/SetHeaders.cpp +73 -0
  53. data/ext/apache2/SetHeaders.cpp.erb +88 -0
  54. data/ext/boost/algorithm/string/detail/find_format.hpp +5 -5
  55. data/ext/boost/algorithm/string/detail/find_format_all.hpp +5 -5
  56. data/ext/boost/algorithm/string/detail/finder.hpp +1 -1
  57. data/ext/boost/algorithm/string/formatter.hpp +2 -2
  58. data/ext/boost/assert.hpp +6 -1
  59. data/ext/boost/atomic.hpp +18 -0
  60. data/ext/boost/atomic/atomic.hpp +241 -0
  61. data/ext/boost/atomic/detail/base.hpp +585 -0
  62. data/ext/boost/atomic/detail/cas32strong.hpp +885 -0
  63. data/ext/boost/atomic/detail/cas32weak.hpp +947 -0
  64. data/ext/boost/atomic/detail/cas64strong.hpp +443 -0
  65. data/ext/boost/atomic/detail/config.hpp +54 -0
  66. data/ext/boost/atomic/detail/gcc-alpha.hpp +368 -0
  67. data/ext/boost/atomic/detail/gcc-armv6plus.hpp +252 -0
  68. data/ext/boost/atomic/detail/gcc-cas.hpp +157 -0
  69. data/ext/boost/atomic/detail/gcc-ppc.hpp +2850 -0
  70. data/ext/boost/atomic/detail/gcc-sparcv9.hpp +1259 -0
  71. data/ext/boost/atomic/detail/gcc-x86.hpp +1766 -0
  72. data/ext/boost/atomic/detail/generic-cas.hpp +206 -0
  73. data/ext/boost/atomic/detail/interlocked.hpp +200 -0
  74. data/ext/boost/atomic/detail/linux-arm.hpp +189 -0
  75. data/ext/boost/atomic/detail/lockpool.hpp +97 -0
  76. data/ext/boost/atomic/detail/platform.hpp +62 -0
  77. data/ext/boost/atomic/detail/type-classification.hpp +45 -0
  78. data/ext/boost/chrono/config.hpp +8 -3
  79. data/ext/boost/chrono/duration.hpp +9 -10
  80. data/ext/boost/chrono/system_clocks.hpp +1 -1
  81. data/ext/boost/chrono/time_point.hpp +4 -3
  82. data/ext/boost/config/auto_link.hpp +53 -52
  83. data/ext/boost/config/compiler/borland.hpp +1 -0
  84. data/ext/boost/config/compiler/clang.hpp +24 -1
  85. data/ext/boost/config/compiler/codegear.hpp +1 -0
  86. data/ext/boost/config/compiler/common_edg.hpp +1 -0
  87. data/ext/boost/config/compiler/cray.hpp +1 -0
  88. data/ext/boost/config/compiler/digitalmars.hpp +1 -0
  89. data/ext/boost/config/compiler/gcc.hpp +29 -3
  90. data/ext/boost/config/compiler/gcc_xml.hpp +2 -1
  91. data/ext/boost/config/compiler/hp_acc.hpp +1 -0
  92. data/ext/boost/config/compiler/intel.hpp +1 -1
  93. data/ext/boost/config/compiler/metrowerks.hpp +1 -0
  94. data/ext/boost/config/compiler/mpw.hpp +1 -0
  95. data/ext/boost/config/compiler/pathscale.hpp +1 -0
  96. data/ext/boost/config/compiler/pgi.hpp +1 -0
  97. data/ext/boost/config/compiler/sunpro_cc.hpp +1 -0
  98. data/ext/boost/config/compiler/vacpp.hpp +3 -2
  99. data/ext/boost/config/compiler/visualc.hpp +25 -11
  100. data/ext/boost/config/platform/vxworks.hpp +353 -15
  101. data/ext/boost/config/select_compiler_config.hpp +4 -4
  102. data/ext/boost/config/stdlib/dinkumware.hpp +10 -3
  103. data/ext/boost/config/stdlib/libstdcpp3.hpp +2 -1
  104. data/ext/boost/config/suffix.hpp +45 -19
  105. data/ext/boost/date_time/format_date_parser.hpp +1 -11
  106. data/ext/boost/date_time/strings_from_facet.hpp +5 -3
  107. data/ext/boost/detail/atomic_redef_macros.hpp +19 -0
  108. data/ext/boost/detail/atomic_undef_macros.hpp +39 -0
  109. data/ext/boost/detail/endian.hpp +52 -4
  110. data/ext/boost/detail/scoped_enum_emulation.hpp +10 -10
  111. data/ext/boost/detail/select_type.hpp +36 -0
  112. data/ext/boost/exception/current_exception_cast.hpp +1 -1
  113. data/ext/boost/exception/detail/error_info_impl.hpp +3 -5
  114. data/ext/boost/exception/detail/exception_ptr.hpp +3 -3
  115. data/ext/boost/exception/detail/is_output_streamable.hpp +1 -1
  116. data/ext/boost/exception/detail/object_hex_dump.hpp +1 -1
  117. data/ext/boost/exception/detail/type_info.hpp +1 -1
  118. data/ext/boost/exception/diagnostic_information.hpp +15 -14
  119. data/ext/boost/exception/exception.hpp +1 -1
  120. data/ext/boost/exception/get_error_info.hpp +1 -1
  121. data/ext/boost/exception/info.hpp +12 -13
  122. data/ext/boost/exception/to_string.hpp +6 -1
  123. data/ext/boost/exception/to_string_stub.hpp +9 -1
  124. data/ext/boost/foreach.hpp +5 -5
  125. data/ext/boost/function/function_template.hpp +6 -6
  126. data/ext/boost/functional/hash/detail/float_functions.hpp +90 -0
  127. data/ext/boost/functional/hash/detail/hash_float.hpp +11 -2
  128. data/ext/boost/functional/hash/extensions.hpp +14 -2
  129. data/ext/boost/functional/hash/hash.hpp +26 -5
  130. data/ext/boost/get_pointer.hpp +17 -2
  131. data/ext/boost/integer_traits.hpp +1 -1
  132. data/ext/boost/lexical_cast.hpp +615 -395
  133. data/ext/boost/libs/atomic/lockpool.cpp +24 -0
  134. data/ext/boost/libs/system/src/error_code.cpp +25 -18
  135. data/ext/boost/libs/thread/src/future.cpp +7 -5
  136. data/ext/boost/libs/thread/src/pthread/once.cpp +9 -3
  137. data/ext/boost/libs/thread/src/pthread/once_atomic.cpp +90 -0
  138. data/ext/boost/libs/thread/src/pthread/thread.cpp +129 -95
  139. data/ext/boost/libs/thread/src/pthread/timeconv.inl +20 -1
  140. data/ext/boost/limits.hpp +1 -1
  141. data/ext/boost/math/policies/policy.hpp +10 -0
  142. data/ext/boost/math/special_functions/detail/round_fwd.hpp +17 -4
  143. data/ext/boost/math/special_functions/fpclassify.hpp +114 -45
  144. data/ext/boost/math/special_functions/math_fwd.hpp +195 -83
  145. data/ext/boost/math/special_functions/sign.hpp +13 -8
  146. data/ext/boost/math/tools/config.hpp +38 -16
  147. data/ext/boost/move/algorithm.hpp +275 -0
  148. data/ext/boost/move/core.hpp +332 -0
  149. data/ext/boost/move/detail/config_begin.hpp +23 -0
  150. data/ext/boost/move/detail/config_end.hpp +20 -0
  151. data/ext/boost/move/detail/meta_utils.hpp +158 -0
  152. data/ext/boost/move/iterator.hpp +298 -0
  153. data/ext/boost/move/move.hpp +10 -1256
  154. data/ext/boost/move/traits.hpp +142 -0
  155. data/ext/boost/move/utility.hpp +194 -0
  156. data/ext/boost/mpl/assert.hpp +72 -4
  157. data/ext/boost/noncopyable.hpp +15 -3
  158. data/ext/boost/pointer_to_other.hpp +55 -0
  159. data/ext/boost/range/concepts.hpp +4 -4
  160. data/ext/boost/range/detail/extract_optional_type.hpp +1 -1
  161. data/ext/boost/range/empty.hpp +1 -1
  162. data/ext/boost/range/iterator_range_core.hpp +4 -1
  163. data/ext/boost/range/iterator_range_io.hpp +2 -2
  164. data/ext/boost/ratio/config.hpp +6 -0
  165. data/ext/boost/ratio/detail/overflow_helpers.hpp +2 -2
  166. data/ext/boost/smart_ptr/allocate_shared_array.hpp +250 -0
  167. data/ext/boost/smart_ptr/detail/allocate_array_helper.hpp +169 -0
  168. data/ext/boost/smart_ptr/detail/array_deleter.hpp +124 -0
  169. data/ext/boost/smart_ptr/detail/array_traits.hpp +53 -0
  170. data/ext/boost/smart_ptr/detail/array_utility.hpp +178 -0
  171. data/ext/boost/smart_ptr/detail/make_array_helper.hpp +157 -0
  172. data/ext/boost/smart_ptr/detail/operator_bool.hpp +16 -9
  173. data/ext/boost/smart_ptr/detail/shared_count.hpp +78 -7
  174. data/ext/boost/smart_ptr/detail/sp_convertible.hpp +15 -0
  175. data/ext/boost/smart_ptr/detail/sp_counted_base.hpp +12 -6
  176. data/ext/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp +1 -0
  177. data/ext/boost/smart_ptr/detail/sp_counted_base_aix.hpp +1 -0
  178. data/ext/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp +1 -0
  179. data/ext/boost/smart_ptr/detail/sp_counted_base_cw_x86.hpp +1 -0
  180. data/ext/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp +1 -0
  181. data/ext/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp +1 -0
  182. data/ext/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp +1 -0
  183. data/ext/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp +1 -0
  184. data/ext/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp +1 -0
  185. data/ext/boost/smart_ptr/detail/sp_counted_base_nt.hpp +1 -0
  186. data/ext/boost/smart_ptr/detail/sp_counted_base_pt.hpp +1 -0
  187. data/ext/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp +162 -0
  188. data/ext/boost/smart_ptr/detail/sp_counted_base_solaris.hpp +1 -0
  189. data/ext/boost/smart_ptr/detail/sp_counted_base_spin.hpp +1 -0
  190. data/ext/boost/smart_ptr/detail/sp_counted_base_sync.hpp +1 -0
  191. data/ext/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp +1 -0
  192. data/ext/boost/smart_ptr/detail/sp_counted_impl.hpp +15 -0
  193. data/ext/boost/smart_ptr/detail/sp_forward.hpp +39 -0
  194. data/ext/boost/smart_ptr/detail/sp_has_sync.hpp +19 -3
  195. data/ext/boost/smart_ptr/detail/sp_if_array.hpp +31 -0
  196. data/ext/boost/smart_ptr/detail/sp_nullptr_t.hpp +45 -0
  197. data/ext/boost/smart_ptr/detail/spinlock_gcc_arm.hpp +5 -12
  198. data/ext/boost/smart_ptr/enable_shared_from_this.hpp +4 -4
  199. data/ext/boost/smart_ptr/make_shared.hpp +5 -1060
  200. data/ext/boost/smart_ptr/make_shared_array.hpp +247 -0
  201. data/ext/boost/smart_ptr/make_shared_object.hpp +1128 -0
  202. data/ext/boost/smart_ptr/scoped_array.hpp +32 -7
  203. data/ext/boost/smart_ptr/scoped_ptr.hpp +31 -5
  204. data/ext/boost/smart_ptr/shared_array.hpp +135 -20
  205. data/ext/boost/smart_ptr/shared_ptr.hpp +444 -126
  206. data/ext/boost/smart_ptr/weak_ptr.hpp +39 -28
  207. data/ext/boost/static_assert.hpp +74 -17
  208. data/ext/boost/system/error_code.hpp +76 -68
  209. data/ext/boost/system/system_error.hpp +5 -1
  210. data/ext/boost/thread/barrier.hpp +6 -2
  211. data/ext/boost/thread/completion_latch.hpp +233 -0
  212. data/ext/boost/thread/condition.hpp +6 -1
  213. data/ext/boost/thread/detail/async_func.hpp +571 -0
  214. data/ext/boost/thread/detail/config.hpp +248 -40
  215. data/ext/boost/thread/detail/counter.hpp +93 -0
  216. data/ext/boost/thread/detail/delete.hpp +12 -0
  217. data/ext/boost/thread/detail/invoke.hpp +1351 -0
  218. data/ext/boost/thread/detail/is_convertible.hpp +48 -0
  219. data/ext/boost/thread/detail/lockable_wrapper.hpp +45 -0
  220. data/ext/boost/thread/detail/log.hpp +83 -0
  221. data/ext/boost/thread/detail/make_tuple_indices.hpp +224 -0
  222. data/ext/boost/thread/detail/move.hpp +32 -16
  223. data/ext/boost/thread/detail/thread.hpp +236 -41
  224. data/ext/boost/thread/detail/thread_group.hpp +55 -9
  225. data/ext/boost/thread/detail/thread_interruption.hpp +4 -1
  226. data/ext/boost/thread/exceptions.hpp +2 -0
  227. data/ext/boost/thread/externally_locked.hpp +351 -0
  228. data/ext/boost/thread/externally_locked_stream.hpp +170 -0
  229. data/ext/boost/thread/future.hpp +2517 -455
  230. data/ext/boost/thread/future_error_code.hpp +61 -0
  231. data/ext/boost/thread/is_locked_by_this_thread.hpp +39 -0
  232. data/ext/boost/thread/latch.hpp +142 -0
  233. data/ext/boost/thread/lock_algorithms.hpp +468 -0
  234. data/ext/boost/thread/lock_concepts.hpp +197 -0
  235. data/ext/boost/thread/lock_factories.hpp +78 -0
  236. data/ext/boost/thread/lock_guard.hpp +88 -0
  237. data/ext/boost/thread/lock_options.hpp +31 -0
  238. data/ext/boost/thread/lock_traits.hpp +45 -0
  239. data/ext/boost/thread/lock_types.hpp +1226 -0
  240. data/ext/boost/thread/lockable_adapter.hpp +226 -0
  241. data/ext/boost/thread/lockable_concepts.hpp +157 -0
  242. data/ext/boost/thread/lockable_traits.hpp +207 -0
  243. data/ext/boost/thread/locks.hpp +5 -1816
  244. data/ext/boost/thread/mutex.hpp +33 -1
  245. data/ext/boost/thread/null_mutex.hpp +243 -0
  246. data/ext/boost/thread/once.hpp +10 -1
  247. data/ext/boost/thread/poly_lockable.hpp +68 -0
  248. data/ext/boost/thread/poly_lockable_adapter.hpp +89 -0
  249. data/ext/boost/thread/poly_shared_lockable.hpp +135 -0
  250. data/ext/boost/thread/poly_shared_lockable_adapter.hpp +170 -0
  251. data/ext/boost/thread/pthread/condition_variable.hpp +74 -26
  252. data/ext/boost/thread/pthread/condition_variable_fwd.hpp +54 -27
  253. data/ext/boost/thread/pthread/mutex.hpp +101 -38
  254. data/ext/boost/thread/pthread/once.hpp +459 -44
  255. data/ext/boost/thread/pthread/once_atomic.hpp +313 -0
  256. data/ext/boost/thread/pthread/recursive_mutex.hpp +19 -10
  257. data/ext/boost/thread/pthread/shared_mutex.hpp +226 -61
  258. data/ext/boost/thread/pthread/shared_mutex_assert.hpp +724 -0
  259. data/ext/boost/thread/pthread/thread_data.hpp +53 -50
  260. data/ext/boost/thread/pthread/timespec.hpp +96 -12
  261. data/ext/boost/thread/recursive_mutex.hpp +44 -1
  262. data/ext/boost/thread/reverse_lock.hpp +3 -2
  263. data/ext/boost/thread/scoped_thread.hpp +285 -0
  264. data/ext/boost/thread/shared_lock_guard.hpp +2 -1
  265. data/ext/boost/thread/shared_mutex.hpp +23 -0
  266. data/ext/boost/thread/strict_lock.hpp +235 -0
  267. data/ext/boost/thread/sync_bounded_queue.hpp +594 -0
  268. data/ext/boost/thread/sync_queue.hpp +516 -0
  269. data/ext/boost/thread/synchronized_value.hpp +1001 -0
  270. data/ext/boost/thread/testable_mutex.hpp +148 -0
  271. data/ext/boost/thread/thread.hpp +1 -13
  272. data/ext/boost/thread/thread_functors.hpp +57 -0
  273. data/ext/boost/thread/thread_guard.hpp +46 -0
  274. data/ext/boost/thread/thread_only.hpp +29 -0
  275. data/ext/boost/thread/v2/shared_mutex.hpp +1062 -0
  276. data/ext/boost/thread/v2/thread.hpp +37 -10
  277. data/ext/boost/thread/xtime.hpp +2 -1
  278. data/ext/boost/token_functions.hpp +16 -16
  279. data/ext/boost/type_traits/add_lvalue_reference.hpp +26 -0
  280. data/ext/boost/type_traits/add_reference.hpp +1 -1
  281. data/ext/boost/type_traits/add_rvalue_reference.hpp +4 -4
  282. data/ext/boost/type_traits/aligned_storage.hpp +13 -0
  283. data/ext/boost/type_traits/common_type.hpp +11 -12
  284. data/ext/boost/type_traits/config.hpp +1 -1
  285. data/ext/boost/type_traits/detail/common_type_imp.hpp +1 -1
  286. data/ext/boost/type_traits/detail/has_binary_operator.hpp +1 -1
  287. data/ext/boost/type_traits/detail/is_function_ptr_tester.hpp +1 -1
  288. data/ext/boost/type_traits/has_left_shift.hpp +49 -0
  289. data/ext/boost/type_traits/has_right_shift.hpp +49 -0
  290. data/ext/boost/type_traits/has_trivial_move_assign.hpp +57 -0
  291. data/ext/boost/type_traits/has_trivial_move_constructor.hpp +57 -0
  292. data/ext/boost/type_traits/intrinsics.hpp +18 -2
  293. data/ext/boost/type_traits/is_abstract.hpp +1 -1
  294. data/ext/boost/type_traits/is_array.hpp +1 -1
  295. data/ext/boost/type_traits/is_const.hpp +1 -1
  296. data/ext/boost/type_traits/is_convertible.hpp +78 -17
  297. data/ext/boost/type_traits/is_function.hpp +6 -1
  298. data/ext/boost/type_traits/is_integral.hpp +6 -1
  299. data/ext/boost/type_traits/is_nothrow_move_assignable.hpp +84 -0
  300. data/ext/boost/type_traits/is_nothrow_move_constructible.hpp +84 -0
  301. data/ext/boost/type_traits/is_pod.hpp +3 -1
  302. data/ext/boost/type_traits/is_rvalue_reference.hpp +1 -1
  303. data/ext/boost/type_traits/is_volatile.hpp +1 -1
  304. data/ext/boost/type_traits/make_signed.hpp +153 -0
  305. data/ext/boost/type_traits/make_unsigned.hpp +16 -0
  306. data/ext/boost/type_traits/remove_const.hpp +1 -1
  307. data/ext/boost/type_traits/remove_cv.hpp +1 -1
  308. data/ext/boost/type_traits/remove_reference.hpp +1 -1
  309. data/ext/boost/type_traits/remove_volatile.hpp +1 -1
  310. data/ext/boost/unordered/detail/allocate.hpp +1120 -0
  311. data/ext/boost/unordered/detail/buckets.hpp +876 -0
  312. data/ext/boost/unordered/detail/equivalent.hpp +680 -0
  313. data/ext/boost/unordered/detail/extract_key.hpp +183 -0
  314. data/ext/boost/unordered/detail/fwd.hpp +23 -0
  315. data/ext/boost/unordered/detail/table.hpp +861 -0
  316. data/ext/boost/unordered/detail/unique.hpp +622 -0
  317. data/ext/boost/unordered/detail/util.hpp +260 -0
  318. data/ext/boost/unordered/unordered_map.hpp +1652 -0
  319. data/ext/boost/unordered/unordered_map_fwd.hpp +65 -0
  320. data/ext/boost/unordered/unordered_set.hpp +1549 -0
  321. data/ext/boost/unordered/unordered_set_fwd.hpp +63 -0
  322. data/ext/boost/unordered_map.hpp +18 -0
  323. data/ext/boost/unordered_set.hpp +18 -0
  324. data/ext/boost/utility/addressof.hpp +2 -2
  325. data/ext/boost/utility/result_of.hpp +8 -1
  326. data/ext/boost/version.hpp +2 -2
  327. data/ext/common/Account.h +1 -1
  328. data/ext/common/AccountsDatabase.h +1 -1
  329. data/ext/common/AgentsStarter.cpp +3 -1
  330. data/ext/common/AgentsStarter.h +2 -2
  331. data/ext/common/ApplicationPool2/AppTypes.cpp +24 -6
  332. data/ext/common/ApplicationPool2/AppTypes.h +17 -8
  333. data/ext/common/ApplicationPool2/Common.h +12 -12
  334. data/ext/common/ApplicationPool2/DirectSpawner.h +2 -2
  335. data/ext/common/ApplicationPool2/DummySpawner.h +3 -3
  336. data/ext/common/ApplicationPool2/Group.h +6 -6
  337. data/ext/common/ApplicationPool2/Implementation.cpp +19 -19
  338. data/ext/common/ApplicationPool2/PipeWatcher.h +5 -5
  339. data/ext/common/ApplicationPool2/Pool.h +21 -21
  340. data/ext/common/ApplicationPool2/Process.h +6 -6
  341. data/ext/common/ApplicationPool2/Session.h +1 -1
  342. data/ext/common/ApplicationPool2/SmartSpawner.h +24 -12
  343. data/ext/common/ApplicationPool2/Socket.h +2 -2
  344. data/ext/common/ApplicationPool2/Spawner.h +64 -14
  345. data/ext/common/ApplicationPool2/SpawnerFactory.h +7 -7
  346. data/ext/common/ApplicationPool2/SuperGroup.h +5 -5
  347. data/ext/common/BackgroundEventLoop.cpp +4 -4
  348. data/ext/common/BackgroundEventLoop.h +1 -1
  349. data/ext/common/Constants.h +13 -1
  350. data/ext/common/EventedBufferedInput.h +8 -8
  351. data/ext/common/Exceptions.cpp +71 -0
  352. data/ext/common/Exceptions.h +60 -7
  353. data/ext/common/FileDescriptor.h +4 -4
  354. data/ext/common/MessageClient.h +1 -1
  355. data/ext/common/MessageServer.h +5 -5
  356. data/ext/common/MultiLibeio.cpp +3 -3
  357. data/ext/common/MultiLibeio.h +2 -2
  358. data/ext/common/RandomGenerator.h +11 -11
  359. data/ext/common/ResourceLocator.h +8 -1
  360. data/ext/common/SafeLibev.h +12 -12
  361. data/ext/common/ServerInstanceDir.h +11 -3
  362. data/ext/common/UnionStation.h +10 -10
  363. data/ext/common/Utils.cpp +11 -13
  364. data/ext/common/Utils.h +9 -9
  365. data/ext/common/Utils/BlockingQueue.h +10 -10
  366. data/ext/common/Utils/BufferedIO.h +1 -1
  367. data/ext/common/Utils/CachedFileStat.hpp +2 -2
  368. data/ext/common/Utils/FileChangeChecker.h +1 -1
  369. data/ext/common/Utils/HashMap.h +13 -4
  370. data/ext/common/Utils/IOUtils.cpp +33 -10
  371. data/ext/common/Utils/IniFile.h +3 -3
  372. data/ext/common/Utils/Lock.h +2 -2
  373. data/ext/common/Utils/MessagePassing.h +10 -10
  374. data/ext/common/Utils/ProcessMetricsCollector.h +24 -6
  375. data/ext/common/Utils/ScopeGuard.h +5 -5
  376. data/ext/common/Utils/jsoncpp.cpp +2 -0
  377. data/ext/common/agents/HelperAgent/FileBackedPipe.h +26 -26
  378. data/ext/common/agents/HelperAgent/Main.cpp +18 -18
  379. data/ext/common/agents/HelperAgent/RequestHandler.cpp +4 -4
  380. data/ext/common/agents/HelperAgent/RequestHandler.h +30 -21
  381. data/ext/common/agents/LoggingAgent/AdminController.h +1 -1
  382. data/ext/common/agents/LoggingAgent/FilterSupport.h +13 -11
  383. data/ext/common/agents/LoggingAgent/LoggingServer.h +11 -11
  384. data/ext/common/agents/LoggingAgent/Main.cpp +9 -9
  385. data/ext/common/agents/LoggingAgent/RemoteSender.h +3 -3
  386. data/ext/common/agents/SpawnPreparer.cpp +1 -0
  387. data/ext/common/agents/Watchdog/AgentWatcher.cpp +8 -7
  388. data/ext/common/agents/Watchdog/Main.cpp +81 -73
  389. data/ext/common/agents/Watchdog/ServerInstanceDirToucher.cpp +1 -1
  390. data/ext/libev/Changes +57 -0
  391. data/ext/libev/LICENSE +2 -1
  392. data/ext/libev/Makefile.in +110 -50
  393. data/ext/libev/README +8 -8
  394. data/ext/libev/aclocal.m4 +1503 -861
  395. data/ext/libev/config.guess +290 -304
  396. data/ext/libev/config.sub +77 -198
  397. data/ext/libev/configure +1735 -890
  398. data/ext/libev/configure.ac +3 -2
  399. data/ext/libev/ev++.h +6 -6
  400. data/ext/libev/ev.c +541 -214
  401. data/ext/libev/ev.h +106 -100
  402. data/ext/libev/ev_epoll.c +1 -1
  403. data/ext/libev/ev_kqueue.c +20 -4
  404. data/ext/libev/ev_vars.h +15 -16
  405. data/ext/libev/ev_win32.c +12 -2
  406. data/ext/libev/ev_wrap.h +162 -160
  407. data/ext/libev/event.c +29 -6
  408. data/ext/libev/event.h +9 -2
  409. data/ext/libev/ltmain.sh +2632 -1384
  410. data/ext/nginx/ConfigurationCommands.c +1 -1
  411. data/ext/nginx/ConfigurationCommands.c.erb +3 -1
  412. data/ext/nginx/ContentHandler.c +25 -2
  413. data/ext/nginx/CreateLocationConfig.c +1 -0
  414. data/ext/nginx/CreateLocationConfig.c.erb +1 -1
  415. data/ext/nginx/MergeLocationConfig.c +1 -0
  416. data/ext/nginx/MergeLocationConfig.c.erb +1 -1
  417. data/ext/nginx/config +12 -0
  418. data/ext/oxt/dynamic_thread_group.hpp +7 -4
  419. data/ext/oxt/system_calls.cpp +5 -1
  420. data/ext/oxt/system_calls.hpp +3 -0
  421. data/helper-scripts/node-loader.js +117 -249
  422. data/lib/phusion_passenger.rb +27 -5
  423. data/lib/phusion_passenger/abstract_installer.rb +104 -9
  424. data/lib/phusion_passenger/admin_tools/memory_stats.rb +10 -9
  425. data/lib/phusion_passenger/apache2/config_options.rb +6 -3
  426. data/lib/phusion_passenger/common_library.rb +7 -1
  427. data/lib/phusion_passenger/constants.rb +6 -0
  428. data/lib/phusion_passenger/loader_shared_helpers.rb +7 -4
  429. data/lib/phusion_passenger/nginx/config_options.rb +2 -1
  430. data/lib/phusion_passenger/packaging.rb +3 -0
  431. data/lib/phusion_passenger/platform_info/apache.rb +43 -6
  432. data/lib/phusion_passenger/platform_info/apache_detector.rb +15 -5
  433. data/lib/phusion_passenger/platform_info/compiler.rb +167 -32
  434. data/lib/phusion_passenger/platform_info/cxx_portability.rb +133 -77
  435. data/lib/phusion_passenger/platform_info/depcheck.rb +17 -7
  436. data/lib/phusion_passenger/platform_info/depcheck_specs/apache2.rb +3 -3
  437. data/lib/phusion_passenger/platform_info/depcheck_specs/compiler_toolchain.rb +4 -4
  438. data/lib/phusion_passenger/platform_info/depcheck_specs/ruby.rb +5 -6
  439. data/lib/phusion_passenger/platform_info/linux.rb +2 -1
  440. data/lib/phusion_passenger/platform_info/operating_system.rb +1 -1
  441. data/lib/phusion_passenger/platform_info/ruby.rb +18 -3
  442. data/lib/phusion_passenger/standalone/runtime_installer.rb +6 -2
  443. data/lib/phusion_passenger/standalone/start_command.rb +8 -2
  444. data/lib/phusion_passenger/utils/ansi_colors.rb +9 -0
  445. data/lib/phusion_passenger/utils/hosts_file_parser.rb +4 -2
  446. data/node_lib/phusion_passenger/httplib_emulation.js +141 -0
  447. data/node_lib/phusion_passenger/line_reader.js +154 -0
  448. data/node_lib/phusion_passenger/request_handler.js +65 -0
  449. data/node_lib/phusion_passenger/session_protocol_parser.js +113 -0
  450. data/resources/templates/apache2/deployment_example.txt.erb +2 -1
  451. data/resources/templates/apache2/installing_against_a_different_apache.txt.erb +14 -0
  452. data/resources/templates/apache2/multiple_apache_installations_detected.txt.erb +15 -0
  453. data/resources/templates/apache2/possible_solutions_for_compilation_and_installation_problems.txt.erb +4 -5
  454. data/resources/templates/general_error_with_html.html.template +1 -1
  455. data/resources/templates/installer_common/gem_install_permission_problems.txt.erb +17 -0
  456. data/resources/templates/installer_common/low_amount_of_memory_warning.txt.erb +6 -4
  457. data/resources/templates/installer_common/world_inaccessible_directories.txt.erb +16 -0
  458. data/resources/templates/nginx/deployment_example.txt.erb +2 -1
  459. data/resources/templates/nginx/possible_solutions_for_compilation_and_installation_problems.txt.erb +4 -5
  460. data/resources/templates/standalone/config.erb +1 -0
  461. data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +3 -3
  462. data/test/cxx/ApplicationPool2/PoolTest.cpp +4 -4
  463. data/test/cxx/ApplicationPool2/ProcessTest.cpp +5 -5
  464. data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +5 -5
  465. data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +1 -1
  466. data/test/cxx/EventedBufferedInputTest.cpp +6 -6
  467. data/test/cxx/FileBackedPipeTest.cpp +1 -1
  468. data/test/cxx/MessagePassingTest.cpp +1 -1
  469. data/test/cxx/MessageServerTest.cpp +4 -4
  470. data/test/cxx/RequestHandlerTest.cpp +7 -7
  471. data/test/cxx/UnionStationTest.cpp +2 -2
  472. data/test/node/line_reader_spec.js +338 -0
  473. data/test/node/spec_helper.js +27 -0
  474. data/test/ruby/standalone/runtime_installer_spec.rb +2 -1
  475. metadata +131 -22
  476. metadata.gz.asc +7 -7
  477. data/ext/boost/functional/hash/detail/container_fwd_0x.hpp +0 -29
  478. data/ext/boost/lambda/core.hpp +0 -79
  479. data/ext/boost/lambda/detail/actions.hpp +0 -174
  480. data/ext/boost/lambda/detail/arity_code.hpp +0 -110
  481. data/ext/boost/lambda/detail/function_adaptors.hpp +0 -789
  482. data/ext/boost/lambda/detail/is_instance_of.hpp +0 -104
  483. data/ext/boost/lambda/detail/lambda_config.hpp +0 -48
  484. data/ext/boost/lambda/detail/lambda_functor_base.hpp +0 -615
  485. data/ext/boost/lambda/detail/lambda_functors.hpp +0 -324
  486. data/ext/boost/lambda/detail/lambda_fwd.hpp +0 -74
  487. data/ext/boost/lambda/detail/lambda_traits.hpp +0 -578
  488. data/ext/boost/lambda/detail/member_ptr.hpp +0 -737
  489. data/ext/boost/lambda/detail/operator_actions.hpp +0 -139
  490. data/ext/boost/lambda/detail/operator_lambda_func_base.hpp +0 -271
  491. data/ext/boost/lambda/detail/operator_return_type_traits.hpp +0 -917
  492. data/ext/boost/lambda/detail/operators.hpp +0 -370
  493. data/ext/boost/lambda/detail/ret.hpp +0 -325
  494. data/ext/boost/lambda/detail/return_type_traits.hpp +0 -282
  495. data/ext/boost/lambda/detail/select_functions.hpp +0 -74
  496. data/ext/boost/lambda/lambda.hpp +0 -34
@@ -677,7 +677,7 @@ namespace boost {
677
677
 
678
678
  vtable_type* get_vtable() const {
679
679
  return reinterpret_cast<vtable_type*>(
680
- reinterpret_cast<std::size_t>(vtable) & ~static_cast<size_t>(0x01));
680
+ reinterpret_cast<std::size_t>(vtable) & ~static_cast<std::size_t>(0x01));
681
681
  }
682
682
 
683
683
  struct clear_type {};
@@ -749,7 +749,7 @@ namespace boost {
749
749
  this->assign_to_own(f);
750
750
  }
751
751
 
752
- #ifndef BOOST_NO_RVALUE_REFERENCES
752
+ #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
753
753
  BOOST_FUNCTION_FUNCTION(BOOST_FUNCTION_FUNCTION&& f) : function_base()
754
754
  {
755
755
  this->move_assign(f);
@@ -838,7 +838,7 @@ namespace boost {
838
838
  return *this;
839
839
  }
840
840
 
841
- #ifndef BOOST_NO_RVALUE_REFERENCES
841
+ #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
842
842
  // Move assignment from another BOOST_FUNCTION_FUNCTION
843
843
  BOOST_FUNCTION_FUNCTION& operator=(BOOST_FUNCTION_FUNCTION&& f)
844
844
  {
@@ -1090,7 +1090,7 @@ public:
1090
1090
 
1091
1091
  function(const base_type& f) : base_type(static_cast<const base_type&>(f)){}
1092
1092
 
1093
- #ifndef BOOST_NO_RVALUE_REFERENCES
1093
+ #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1094
1094
  // Move constructors
1095
1095
  function(self_type&& f): base_type(static_cast<base_type&&>(f)){}
1096
1096
  function(base_type&& f): base_type(static_cast<base_type&&>(f)){}
@@ -1102,7 +1102,7 @@ public:
1102
1102
  return *this;
1103
1103
  }
1104
1104
 
1105
- #ifndef BOOST_NO_RVALUE_REFERENCES
1105
+ #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1106
1106
  self_type& operator=(self_type&& f)
1107
1107
  {
1108
1108
  self_type(static_cast<self_type&&>(f)).swap(*this);
@@ -1139,7 +1139,7 @@ public:
1139
1139
  return *this;
1140
1140
  }
1141
1141
 
1142
- #ifndef BOOST_NO_RVALUE_REFERENCES
1142
+ #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1143
1143
  self_type& operator=(base_type&& f)
1144
1144
  {
1145
1145
  self_type(static_cast<base_type&&>(f)).swap(*this);
@@ -13,6 +13,94 @@
13
13
  # pragma once
14
14
  #endif
15
15
 
16
+ // Set BOOST_HASH_CONFORMANT_FLOATS to 1 for libraries known to have
17
+ // sufficiently good floating point support to not require any
18
+ // workarounds.
19
+ //
20
+ // When set to 0, the library tries to automatically
21
+ // use the best available implementation. This normally works well, but
22
+ // breaks when ambiguities are created by odd namespacing of the functions.
23
+ //
24
+ // Note that if this is set to 0, the library should still take full
25
+ // advantage of the platform's floating point support.
26
+
27
+ #if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
28
+ # define BOOST_HASH_CONFORMANT_FLOATS 0
29
+ #elif defined(__LIBCOMO__)
30
+ # define BOOST_HASH_CONFORMANT_FLOATS 0
31
+ #elif defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER)
32
+ // Rogue Wave library:
33
+ # define BOOST_HASH_CONFORMANT_FLOATS 0
34
+ #elif defined(_LIBCPP_VERSION)
35
+ // libc++
36
+ # define BOOST_HASH_CONFORMANT_FLOATS 1
37
+ #elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
38
+ // GNU libstdc++ 3
39
+ # if defined(__GNUC__) && __GNUC__ >= 4
40
+ # define BOOST_HASH_CONFORMANT_FLOATS 1
41
+ # else
42
+ # define BOOST_HASH_CONFORMANT_FLOATS 0
43
+ # endif
44
+ #elif defined(__STL_CONFIG_H)
45
+ // generic SGI STL
46
+ # define BOOST_HASH_CONFORMANT_FLOATS 0
47
+ #elif defined(__MSL_CPP__)
48
+ // MSL standard lib:
49
+ # define BOOST_HASH_CONFORMANT_FLOATS 0
50
+ #elif defined(__IBMCPP__)
51
+ // VACPP std lib (probably conformant for much earlier version).
52
+ # if __IBMCPP__ >= 1210
53
+ # define BOOST_HASH_CONFORMANT_FLOATS 1
54
+ # else
55
+ # define BOOST_HASH_CONFORMANT_FLOATS 0
56
+ # endif
57
+ #elif defined(MSIPL_COMPILE_H)
58
+ // Modena C++ standard library
59
+ # define BOOST_HASH_CONFORMANT_FLOATS 0
60
+ #elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER)
61
+ // Dinkumware Library (this has to appear after any possible replacement libraries):
62
+ # if _CPPLIB_VER >= 405
63
+ # define BOOST_HASH_CONFORMANT_FLOATS 1
64
+ # else
65
+ # define BOOST_HASH_CONFORMANT_FLOATS 0
66
+ # endif
67
+ #else
68
+ # define BOOST_HASH_CONFORMANT_FLOATS 0
69
+ #endif
70
+
71
+ #if BOOST_HASH_CONFORMANT_FLOATS
72
+
73
+ // The standard library is known to be compliant, so don't use the
74
+ // configuration mechanism.
75
+
76
+ namespace boost {
77
+ namespace hash_detail {
78
+ template <typename Float>
79
+ struct call_ldexp {
80
+ typedef Float float_type;
81
+ inline Float operator()(Float x, int y) const {
82
+ return std::ldexp(x, y);
83
+ }
84
+ };
85
+
86
+ template <typename Float>
87
+ struct call_frexp {
88
+ typedef Float float_type;
89
+ inline Float operator()(Float x, int* y) const {
90
+ return std::frexp(x, y);
91
+ }
92
+ };
93
+
94
+ template <typename Float>
95
+ struct select_hash_type
96
+ {
97
+ typedef Float type;
98
+ };
99
+ }
100
+ }
101
+
102
+ #else // BOOST_HASH_CONFORMANT_FLOATS == 0
103
+
16
104
  // The C++ standard requires that the C float functions are overloarded
17
105
  // for float, double and long double in the std namespace, but some of the older
18
106
  // library implementations don't support this. On some that don't, the C99
@@ -243,4 +331,6 @@ namespace boost
243
331
  }
244
332
  }
245
333
 
334
+ #endif // BOOST_HASH_CONFORMANT_FLOATS
335
+
246
336
  #endif
@@ -73,7 +73,9 @@ namespace boost
73
73
  ptr += sizeof(std::size_t);
74
74
 
75
75
  while(length >= sizeof(std::size_t)) {
76
- hash_float_combine(seed, *(std::size_t*) ptr);
76
+ std::size_t buffer = 0;
77
+ std::memcpy(&buffer, ptr, sizeof(std::size_t));
78
+ hash_float_combine(seed, buffer);
77
79
  length -= sizeof(std::size_t);
78
80
  ptr += sizeof(std::size_t);
79
81
  }
@@ -210,8 +212,15 @@ namespace boost
210
212
  template <class T>
211
213
  inline std::size_t float_hash_value(T v)
212
214
  {
215
+ #if defined(fpclassify)
216
+ switch (fpclassify(v))
217
+ #elif BOOST_HASH_CONFORMANT_FLOATS
218
+ switch (std::fpclassify(v))
219
+ #else
213
220
  using namespace std;
214
- switch (fpclassify(v)) {
221
+ switch (fpclassify(v))
222
+ #endif
223
+ {
215
224
  case FP_ZERO:
216
225
  return 0;
217
226
  case FP_INFINITE:
@@ -14,12 +14,24 @@
14
14
  #define BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP
15
15
 
16
16
  #include <boost/functional/hash/hash.hpp>
17
- #include <boost/functional/hash/detail/container_fwd_0x.hpp>
17
+ #include <boost/detail/container_fwd.hpp>
18
18
  #include <boost/utility/enable_if.hpp>
19
19
  #include <boost/static_assert.hpp>
20
20
  #include <boost/preprocessor/repetition/repeat_from_to.hpp>
21
21
  #include <boost/preprocessor/repetition/enum_params.hpp>
22
22
 
23
+ #if !defined(BOOST_NO_CXX11_HDR_ARRAY)
24
+ # include <array>
25
+ #endif
26
+
27
+ #if !defined(BOOST_NO_CXX11_HDR_TUPLE)
28
+ # include <tuple>
29
+ #endif
30
+
31
+ #if !defined(BOOST_NO_CXX11_HDR_MEMORY)
32
+ # include <memory>
33
+ #endif
34
+
23
35
  #if defined(_MSC_VER) && (_MSC_VER >= 1020)
24
36
  # pragma once
25
37
  #endif
@@ -149,7 +161,7 @@ namespace boost
149
161
  }
150
162
  }
151
163
 
152
- #if !defined(BOOST_NO_VARIADIC_TEMPLATES)
164
+ #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
153
165
  template <typename... T>
154
166
  inline std::size_t hash_value(std::tuple<T...> const& v)
155
167
  {
@@ -16,6 +16,7 @@
16
16
  #include <string>
17
17
  #include <boost/limits.hpp>
18
18
  #include <boost/type_traits/is_enum.hpp>
19
+ #include <boost/type_traits/is_integral.hpp>
19
20
  #include <boost/utility/enable_if.hpp>
20
21
 
21
22
  #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
@@ -40,8 +41,8 @@ namespace boost
40
41
  struct enable_hash_value { typedef std::size_t type; };
41
42
 
42
43
  template <typename T> struct basic_numbers {};
43
- template <typename T> struct long_numbers {};
44
- template <typename T> struct ulong_numbers {};
44
+ template <typename T> struct long_numbers;
45
+ template <typename T> struct ulong_numbers;
45
46
  template <typename T> struct float_numbers {};
46
47
 
47
48
  template <> struct basic_numbers<bool> :
@@ -70,6 +71,14 @@ namespace boost
70
71
  boost::hash_detail::enable_hash_value {};
71
72
  #endif
72
73
 
74
+ // long_numbers is defined like this to allow for separate
75
+ // specialization for long_long and int128_type, in case
76
+ // they conflict.
77
+ template <typename T> struct long_numbers2 {};
78
+ template <typename T> struct ulong_numbers2 {};
79
+ template <typename T> struct long_numbers : long_numbers2<T> {};
80
+ template <typename T> struct ulong_numbers : ulong_numbers2<T> {};
81
+
73
82
  #if !defined(BOOST_NO_LONG_LONG)
74
83
  template <> struct long_numbers<boost::long_long_type> :
75
84
  boost::hash_detail::enable_hash_value {};
@@ -77,6 +86,13 @@ namespace boost
77
86
  boost::hash_detail::enable_hash_value {};
78
87
  #endif
79
88
 
89
+ #if defined(BOOST_HAS_INT128)
90
+ template <> struct long_numbers2<boost::int128_type> :
91
+ boost::hash_detail::enable_hash_value {};
92
+ template <> struct ulong_numbers2<boost::uint128_type> :
93
+ boost::hash_detail::enable_hash_value {};
94
+ #endif
95
+
80
96
  template <> struct float_numbers<float> :
81
97
  boost::hash_detail::enable_hash_value {};
82
98
  template <> struct float_numbers<double> :
@@ -94,7 +110,7 @@ namespace boost
94
110
 
95
111
  template <typename T>
96
112
  typename boost::enable_if<boost::is_enum<T>, std::size_t>::type
97
- hash_value(T);
113
+ hash_value(T);
98
114
 
99
115
  #if !BOOST_WORKAROUND(__DMC__, <= 0x848)
100
116
  template <class T> std::size_t hash_value(T* const&);
@@ -187,9 +203,9 @@ namespace boost
187
203
 
188
204
  template <typename T>
189
205
  typename boost::enable_if<boost::is_enum<T>, std::size_t>::type
190
- hash_value(T v)
206
+ hash_value(T v)
191
207
  {
192
- return static_cast<std::size_t>(v);
208
+ return static_cast<std::size_t>(v);
193
209
  }
194
210
 
195
211
  // Implementation by Alberto Barbati and Dave Harris.
@@ -423,6 +439,11 @@ namespace boost
423
439
  BOOST_HASH_SPECIALIZE(boost::ulong_long_type)
424
440
  #endif
425
441
 
442
+ #if defined(BOOST_HAS_INT128)
443
+ BOOST_HASH_SPECIALIZE(boost::int128_type)
444
+ BOOST_HASH_SPECIALIZE(boost::uint128_type)
445
+ #endif
446
+
426
447
  #if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX)
427
448
  BOOST_HASH_SPECIALIZE(std::type_index)
428
449
  #endif
@@ -3,13 +3,15 @@
3
3
  // accompanying file LICENSE_1_0.txt or copy at
4
4
  // http://www.boost.org/LICENSE_1_0.txt)
5
5
  #ifndef GET_POINTER_DWA20021219_HPP
6
- # define GET_POINTER_DWA20021219_HPP
6
+ #define GET_POINTER_DWA20021219_HPP
7
+
8
+ #include <boost/config.hpp>
7
9
 
8
10
  // In order to avoid circular dependencies with Boost.TR1
9
11
  // we make sure that our include of <memory> doesn't try to
10
12
  // pull in the TR1 headers: that's why we use this header
11
13
  // rather than including <memory> directly:
12
- # include <boost/config/no_tr1/memory.hpp> // std::auto_ptr
14
+ #include <boost/config/no_tr1/memory.hpp> // std::auto_ptr
13
15
 
14
16
  namespace boost {
15
17
 
@@ -27,6 +29,19 @@ template<class T> T * get_pointer(std::auto_ptr<T> const& p)
27
29
  return p.get();
28
30
  }
29
31
 
32
+ #if !defined( BOOST_NO_CXX11_SMART_PTR )
33
+
34
+ template<class T> T * get_pointer( std::unique_ptr<T> const& p )
35
+ {
36
+ return p.get();
37
+ }
38
+
39
+ template<class T> T * get_pointer( std::shared_ptr<T> const& p )
40
+ {
41
+ return p.get();
42
+ }
43
+
44
+ #endif
30
45
 
31
46
  } // namespace boost
32
47
 
@@ -5,7 +5,7 @@
5
5
  * accompanying file LICENSE_1_0.txt or copy at
6
6
  * http://www.boost.org/LICENSE_1_0.txt)
7
7
  *
8
- * $Id: integer_traits.hpp 80740 2012-09-28 18:34:12Z jewillco $
8
+ * $Id: integer_traits.hpp 83381 2013-03-09 22:55:05Z eric_niebler $
9
9
  *
10
10
  * Idea by Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers
11
11
  */
@@ -19,7 +19,7 @@
19
19
  // Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov,
20
20
  // Alexander Nasonov, Antony Polukhin, Justin Viiret, Michael Hofmann,
21
21
  // Cheng Yang, Matthew Bradbury, David W. Birdsall, Pavel Korzh and other Boosters
22
- // when: November 2000, March 2003, June 2005, June 2006, March 2011 - 2012
22
+ // when: November 2000, March 2003, June 2005, June 2006, March 2011 - 2013
23
23
 
24
24
  #include <boost/config.hpp>
25
25
  #if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING)
@@ -69,6 +69,11 @@
69
69
  throw_exception(bad_lexical_cast(typeid(Source), typeid(Target)))
70
70
  #endif
71
71
 
72
+ #if (defined(BOOST_LCAST_HAS_INT128) && !defined(__GNUC__)) || GCC_VERSION > 40700
73
+ #define BOOST_LCAST_HAS_INT128
74
+ #endif
75
+
76
+
72
77
  namespace boost
73
78
  {
74
79
  // exception used to indicate runtime lexical_cast failure
@@ -112,7 +117,7 @@ namespace boost
112
117
  return *target;
113
118
  }
114
119
 
115
- #ifndef BOOST_NO_NOEXCEPT
120
+ #ifndef BOOST_NO_CXX11_NOEXCEPT
116
121
  virtual const char *what() const noexcept
117
122
  #else
118
123
  virtual const char *what() const throw()
@@ -122,7 +127,7 @@ namespace boost
122
127
  "source type value could not be interpreted as target";
123
128
  }
124
129
 
125
- #ifndef BOOST_NO_NOEXCEPT
130
+ #ifndef BOOST_NO_CXX11_NOEXCEPT
126
131
  virtual ~bad_lexical_cast() BOOST_NOEXCEPT
127
132
  #else
128
133
  virtual ~bad_lexical_cast() throw()
@@ -151,7 +156,7 @@ namespace boost
151
156
  #include <cmath>
152
157
  #include <istream>
153
158
 
154
- #if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
159
+ #ifndef BOOST_NO_CXX11_HDR_ARRAY
155
160
  #include <array>
156
161
  #endif
157
162
 
@@ -162,251 +167,393 @@ namespace boost
162
167
  #include <boost/type_traits/is_integral.hpp>
163
168
  #include <boost/type_traits/is_arithmetic.hpp>
164
169
  #include <boost/type_traits/remove_pointer.hpp>
170
+ #include <boost/type_traits/has_left_shift.hpp>
171
+ #include <boost/type_traits/has_right_shift.hpp>
165
172
  #include <boost/math/special_functions/sign.hpp>
166
173
  #include <boost/math/special_functions/fpclassify.hpp>
167
174
  #include <boost/range/iterator_range_core.hpp>
168
175
  #include <boost/container/container_fwd.hpp>
176
+ #include <boost/integer.hpp>
169
177
  #ifndef BOOST_NO_CWCHAR
170
178
  # include <cwchar>
171
179
  #endif
172
180
 
173
181
  namespace boost {
174
- namespace detail // widest_char<...> (continuation)
175
- {
176
- struct not_a_character_type{};
177
-
178
- template <typename CharT>
179
- struct widest_char<not_a_character_type, CharT >
180
- {
181
- typedef CharT type;
182
- };
183
-
184
- template <typename CharT>
185
- struct widest_char< CharT, not_a_character_type >
186
- {
187
- typedef CharT type;
188
- };
189
-
190
- template <>
191
- struct widest_char< not_a_character_type, not_a_character_type >
192
- {
193
- typedef char type;
194
- };
195
- }
196
182
 
197
- namespace detail // is_char_or_wchar<...> and stream_char<...> templates
183
+ namespace detail // is_char_or_wchar<...>
198
184
  {
199
185
  // returns true, if T is one of the character types
200
- template <typename T>
186
+ template < typename T >
201
187
  struct is_char_or_wchar
202
188
  {
203
- typedef ::boost::type_traits::ice_or<
204
- ::boost::is_same< T, char >::value,
189
+ typedef boost::type_traits::ice_or<
190
+ boost::is_same< T, char >::value,
205
191
  #ifndef BOOST_LCAST_NO_WCHAR_T
206
- ::boost::is_same< T, wchar_t >::value,
192
+ boost::is_same< T, wchar_t >::value,
207
193
  #endif
208
- #ifndef BOOST_NO_CHAR16_T
209
- ::boost::is_same< T, char16_t >::value,
194
+ #ifndef BOOST_NO_CXX11_CHAR16_T
195
+ boost::is_same< T, char16_t >::value,
210
196
  #endif
211
- #ifndef BOOST_NO_CHAR32_T
212
- ::boost::is_same< T, char32_t >::value,
197
+ #ifndef BOOST_NO_CXX11_CHAR32_T
198
+ boost::is_same< T, char32_t >::value,
213
199
  #endif
214
- ::boost::is_same< T, unsigned char >::value,
215
- ::boost::is_same< T, signed char >::value
200
+ boost::is_same< T, unsigned char >::value,
201
+ boost::is_same< T, signed char >::value
216
202
  > result_type;
217
203
 
218
204
  BOOST_STATIC_CONSTANT(bool, value = (result_type::value) );
219
205
  };
206
+ }
220
207
 
221
- // selectors for choosing stream character type
222
- // returns one of char, wchar_t, char16_t, char32_t or not_a_character_type types
223
- template <typename Type>
224
- struct stream_char
208
+ namespace detail // normalize_single_byte_char<Char>
209
+ {
210
+ // Converts signed/unsigned char to char
211
+ template < class Char >
212
+ struct normalize_single_byte_char
225
213
  {
226
- typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c<
227
- is_char_or_wchar<Type >::value,
228
- Type,
229
- boost::detail::not_a_character_type
230
- >::type type;
214
+ typedef Char type;
231
215
  };
232
216
 
233
217
  template <>
234
- struct stream_char<unsigned char>
218
+ struct normalize_single_byte_char< signed char >
235
219
  {
236
220
  typedef char type;
237
221
  };
238
222
 
239
223
  template <>
240
- struct stream_char<signed char>
224
+ struct normalize_single_byte_char< unsigned char >
241
225
  {
242
226
  typedef char type;
243
227
  };
228
+ }
244
229
 
245
- template <typename CharT>
246
- struct stream_char<CharT*>
247
- {
248
- typedef BOOST_DEDUCED_TYPENAME stream_char<CharT>::type type;
249
- };
250
-
251
- template <typename CharT>
252
- struct stream_char<const CharT*>
253
- {
254
- typedef BOOST_DEDUCED_TYPENAME stream_char<CharT>::type type;
255
- };
230
+ namespace detail // deduce_character_type_later<T>
231
+ {
232
+ // Helper type, meaning that stram character for T must be deduced
233
+ // at Stage 2 (See deduce_source_char<T> and deduce_target_char<T>)
234
+ template < class T > struct deduce_character_type_later {};
235
+ }
256
236
 
257
- template <typename CharT>
258
- struct stream_char<iterator_range<CharT*> >
259
- {
260
- typedef BOOST_DEDUCED_TYPENAME stream_char<CharT*>::type type;
261
- };
237
+ namespace detail // stream_char_common<T>
238
+ {
239
+ // Selectors to choose stream character type (common for Source and Target)
240
+ // Returns one of char, wchar_t, char16_t, char32_t or deduce_character_type_later<T> types
241
+ // Executed on Stage 1 (See deduce_source_char<T> and deduce_target_char<T>)
242
+ template < typename Type >
243
+ struct stream_char_common: public boost::mpl::if_c<
244
+ boost::detail::is_char_or_wchar< Type >::value,
245
+ Type,
246
+ boost::detail::deduce_character_type_later< Type >
247
+ > {};
248
+
249
+ template < typename Char >
250
+ struct stream_char_common< Char* >: public boost::mpl::if_c<
251
+ boost::detail::is_char_or_wchar< Char >::value,
252
+ Char,
253
+ boost::detail::deduce_character_type_later< Char* >
254
+ > {};
255
+
256
+ template < typename Char >
257
+ struct stream_char_common< const Char* >: public boost::mpl::if_c<
258
+ boost::detail::is_char_or_wchar< Char >::value,
259
+ Char,
260
+ boost::detail::deduce_character_type_later< const Char* >
261
+ > {};
262
+
263
+ template < typename Char >
264
+ struct stream_char_common< boost::iterator_range< Char* > >: public boost::mpl::if_c<
265
+ boost::detail::is_char_or_wchar< Char >::value,
266
+ Char,
267
+ boost::detail::deduce_character_type_later< boost::iterator_range< Char* > >
268
+ > {};
262
269
 
263
- template <typename CharT>
264
- struct stream_char<iterator_range<const CharT*> >
265
- {
266
- typedef BOOST_DEDUCED_TYPENAME stream_char<const CharT*>::type type;
267
- };
270
+ template < typename Char >
271
+ struct stream_char_common< boost::iterator_range< const Char* > >: public boost::mpl::if_c<
272
+ boost::detail::is_char_or_wchar< Char >::value,
273
+ Char,
274
+ boost::detail::deduce_character_type_later< boost::iterator_range< const Char* > >
275
+ > {};
268
276
 
269
- template <class CharT, class Traits, class Alloc>
270
- struct stream_char< std::basic_string<CharT, Traits, Alloc> >
277
+ template < class Char, class Traits, class Alloc >
278
+ struct stream_char_common< std::basic_string< Char, Traits, Alloc > >
271
279
  {
272
- typedef CharT type;
280
+ typedef Char type;
273
281
  };
274
282
 
275
- template <class CharT, class Traits, class Alloc>
276
- struct stream_char< ::boost::container::basic_string<CharT, Traits, Alloc> >
283
+ template < class Char, class Traits, class Alloc >
284
+ struct stream_char_common< boost::container::basic_string< Char, Traits, Alloc > >
277
285
  {
278
- typedef CharT type;
286
+ typedef Char type;
279
287
  };
280
288
 
281
- template<typename CharT, std::size_t N>
282
- struct stream_char<boost::array<CharT, N> >
283
- {
284
- typedef BOOST_DEDUCED_TYPENAME stream_char<CharT>::type type;
285
- };
289
+ template < typename Char, std::size_t N >
290
+ struct stream_char_common< boost::array< Char, N > >: public boost::mpl::if_c<
291
+ boost::detail::is_char_or_wchar< Char >::value,
292
+ Char,
293
+ boost::detail::deduce_character_type_later< boost::array< Char, N > >
294
+ > {};
286
295
 
287
- template<typename CharT, std::size_t N>
288
- struct stream_char<boost::array<const CharT, N> >
289
- {
290
- typedef BOOST_DEDUCED_TYPENAME stream_char<CharT>::type type;
291
- };
296
+ template < typename Char, std::size_t N >
297
+ struct stream_char_common< boost::array< const Char, N > >: public boost::mpl::if_c<
298
+ boost::detail::is_char_or_wchar< Char >::value,
299
+ Char,
300
+ boost::detail::deduce_character_type_later< boost::array< const Char, N > >
301
+ > {};
302
+
303
+ #ifndef BOOST_NO_CXX11_HDR_ARRAY
304
+ template < typename Char, std::size_t N >
305
+ struct stream_char_common< std::array<Char, N > >: public boost::mpl::if_c<
306
+ boost::detail::is_char_or_wchar< Char >::value,
307
+ Char,
308
+ boost::detail::deduce_character_type_later< std::array< Char, N > >
309
+ > {};
310
+
311
+ template < typename Char, std::size_t N >
312
+ struct stream_char_common< std::array< const Char, N > >: public boost::mpl::if_c<
313
+ boost::detail::is_char_or_wchar< Char >::value,
314
+ Char,
315
+ boost::detail::deduce_character_type_later< std::array< const Char, N > >
316
+ > {};
317
+ #endif
292
318
 
293
- #if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
294
- template <typename CharT, std::size_t N>
295
- struct stream_char<std::array<CharT, N> >
319
+ #ifdef BOOST_LCAST_HAS_INT128
320
+ template <> struct stream_char_common< boost::int128_type >: public boost::mpl::identity< char > {};
321
+ template <> struct stream_char_common< boost::uint128_type >: public boost::mpl::identity< char > {};
322
+ #endif
323
+
324
+ #if !defined(BOOST_LCAST_NO_WCHAR_T) && defined(BOOST_NO_INTRINSIC_WCHAR_T)
325
+ template <>
326
+ struct stream_char_common< wchar_t >
296
327
  {
297
- typedef BOOST_DEDUCED_TYPENAME stream_char<CharT>::type type;
328
+ typedef char type;
298
329
  };
330
+ #endif
331
+ }
299
332
 
300
- template <typename CharT, std::size_t N>
301
- struct stream_char<std::array<const CharT, N> >
302
- {
303
- typedef BOOST_DEDUCED_TYPENAME stream_char<CharT>::type type;
333
+ namespace detail // deduce_source_char_impl<T>
334
+ {
335
+ // If type T is `deduce_character_type_later` type, then tries to deduce
336
+ // character type using boost::has_left_shift<T> metafunction.
337
+ // Otherwise supplied type T is a character type, that must be normalized
338
+ // using normalize_single_byte_char<Char>.
339
+ // Executed at Stage 2 (See deduce_source_char<T> and deduce_target_char<T>)
340
+ template < class Char >
341
+ struct deduce_source_char_impl
342
+ {
343
+ typedef BOOST_DEDUCED_TYPENAME boost::detail::normalize_single_byte_char< Char >::type type;
344
+ };
345
+
346
+ template < class T >
347
+ struct deduce_source_char_impl< deduce_character_type_later< T > >
348
+ {
349
+ typedef boost::has_left_shift< std::basic_ostream< char >, T > result_t;
350
+
351
+ #if defined(BOOST_LCAST_NO_WCHAR_T)
352
+ BOOST_STATIC_ASSERT_MSG((result_t::value),
353
+ "Source type is not std::ostream`able and std::wostream`s are not supported by your STL implementation");
354
+ typedef char type;
355
+ #else
356
+ typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c<
357
+ result_t::value, char, wchar_t
358
+ >::type type;
359
+
360
+ BOOST_STATIC_ASSERT_MSG((result_t::value || boost::has_left_shift< std::basic_ostream< type >, T >::value),
361
+ "Source type is neither std::ostream`able nor std::wostream`able");
362
+ #endif
304
363
  };
305
- #endif // !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
364
+ }
306
365
 
307
- #if !defined(BOOST_LCAST_NO_WCHAR_T) && defined(BOOST_NO_INTRINSIC_WCHAR_T)
308
- template<>
309
- struct stream_char<wchar_t>
310
- {
311
- typedef boost::detail::not_a_character_type type;
366
+ namespace detail // deduce_target_char_impl<T>
367
+ {
368
+ // If type T is `deduce_character_type_later` type, then tries to deduce
369
+ // character type using boost::has_right_shift<T> metafunction.
370
+ // Otherwise supplied type T is a character type, that must be normalized
371
+ // using normalize_single_byte_char<Char>.
372
+ // Executed at Stage 2 (See deduce_source_char<T> and deduce_target_char<T>)
373
+ template < class Char >
374
+ struct deduce_target_char_impl
375
+ {
376
+ typedef BOOST_DEDUCED_TYPENAME normalize_single_byte_char< Char >::type type;
377
+ };
378
+
379
+ template < class T >
380
+ struct deduce_target_char_impl< deduce_character_type_later<T> >
381
+ {
382
+ typedef boost::has_right_shift<std::basic_istream<char>, T > result_t;
383
+
384
+ #if defined(BOOST_LCAST_NO_WCHAR_T)
385
+ BOOST_STATIC_ASSERT_MSG((result_t::value),
386
+ "Target type is not std::istream`able and std::wistream`s are not supported by your STL implementation");
387
+ typedef char type;
388
+ #else
389
+ typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c<
390
+ result_t::value, char, wchar_t
391
+ >::type type;
392
+
393
+ BOOST_STATIC_ASSERT_MSG((result_t::value || boost::has_right_shift<std::basic_istream<wchar_t>, T >::value),
394
+ "Target type is neither std::istream`able nor std::wistream`able");
395
+ #endif
312
396
  };
397
+ }
313
398
 
314
- template<>
315
- struct stream_char<wchar_t*>
399
+ namespace detail // deduce_target_char<T> and deduce_source_char<T>
400
+ {
401
+ // We deduce stream character types in two stages.
402
+ //
403
+ // Stage 1 is common for Target and Source. At Stage 1 we get
404
+ // non normalized character type (may contain unsigned/signed char)
405
+ // or deduce_character_type_later<T> where T is the original type.
406
+ // Stage 1 is executed by stream_char_common<T>
407
+ //
408
+ // At Stage 2 we normalize character types or try to deduce character
409
+ // type using metafunctions.
410
+ // Stage 2 is executed by deduce_target_char_impl<T> and
411
+ // deduce_source_char_impl<T>
412
+ //
413
+ // deduce_target_char<T> and deduce_source_char<T> functions combine
414
+ // both stages
415
+
416
+ template < class T >
417
+ struct deduce_target_char
316
418
  {
317
- typedef wchar_t type;
419
+ typedef BOOST_DEDUCED_TYPENAME stream_char_common< T >::type stage1_type;
420
+ typedef BOOST_DEDUCED_TYPENAME deduce_target_char_impl< stage1_type >::type stage2_type;
421
+
422
+ typedef stage2_type type;
318
423
  };
319
424
 
320
- template<>
321
- struct stream_char<const wchar_t*>
425
+ template < class T >
426
+ struct deduce_source_char
322
427
  {
323
- typedef wchar_t type;
428
+ typedef BOOST_DEDUCED_TYPENAME stream_char_common< T >::type stage1_type;
429
+ typedef BOOST_DEDUCED_TYPENAME deduce_source_char_impl< stage1_type >::type stage2_type;
430
+
431
+ typedef stage2_type type;
324
432
  };
325
- #endif
326
433
  }
327
434
 
328
435
  namespace detail // deduce_char_traits template
329
436
  {
330
-
331
- template<class CharT, class Target, class Source>
437
+ // We are attempting to get char_traits<> from Source or Tagret
438
+ // template parameter. Otherwise we'll be using std::char_traits<Char>
439
+ template < class Char, class Target, class Source >
332
440
  struct deduce_char_traits
333
441
  {
334
- typedef std::char_traits<CharT> type;
442
+ typedef std::char_traits< Char > type;
335
443
  };
336
444
 
337
- template<class CharT, class Traits, class Alloc, class Source>
338
- struct deduce_char_traits< CharT
339
- , std::basic_string<CharT,Traits,Alloc>
445
+ template < class Char, class Traits, class Alloc, class Source >
446
+ struct deduce_char_traits< Char
447
+ , std::basic_string< Char, Traits, Alloc >
340
448
  , Source
341
449
  >
342
450
  {
343
451
  typedef Traits type;
344
452
  };
345
453
 
346
- template<class CharT, class Target, class Traits, class Alloc>
347
- struct deduce_char_traits< CharT
454
+ template < class Char, class Target, class Traits, class Alloc >
455
+ struct deduce_char_traits< Char
348
456
  , Target
349
- , std::basic_string<CharT,Traits,Alloc>
457
+ , std::basic_string< Char, Traits, Alloc >
350
458
  >
351
459
  {
352
460
  typedef Traits type;
353
461
  };
354
462
 
355
- template<class CharT, class Traits, class Alloc, class Source>
356
- struct deduce_char_traits< CharT
357
- , ::boost::container::basic_string<CharT,Traits,Alloc>
463
+ template < class Char, class Traits, class Alloc, class Source >
464
+ struct deduce_char_traits< Char
465
+ , boost::container::basic_string< Char, Traits, Alloc >
358
466
  , Source
359
467
  >
360
468
  {
361
469
  typedef Traits type;
362
470
  };
363
471
 
364
- template<class CharT, class Target, class Traits, class Alloc>
365
- struct deduce_char_traits< CharT
472
+ template < class Char, class Target, class Traits, class Alloc >
473
+ struct deduce_char_traits< Char
366
474
  , Target
367
- , ::boost::container::basic_string<CharT,Traits,Alloc>
475
+ , boost::container::basic_string< Char, Traits, Alloc >
368
476
  >
369
477
  {
370
478
  typedef Traits type;
371
479
  };
372
480
 
373
- template<class CharT, class Traits, class Alloc1, class Alloc2>
374
- struct deduce_char_traits< CharT
375
- , std::basic_string<CharT,Traits,Alloc1>
376
- , std::basic_string<CharT,Traits,Alloc2>
481
+ template < class Char, class Traits, class Alloc1, class Alloc2 >
482
+ struct deduce_char_traits< Char
483
+ , std::basic_string< Char, Traits, Alloc1 >
484
+ , std::basic_string< Char, Traits, Alloc2 >
377
485
  >
378
486
  {
379
487
  typedef Traits type;
380
488
  };
381
489
 
382
- template<class CharT, class Traits, class Alloc1, class Alloc2>
383
- struct deduce_char_traits< CharT
384
- , ::boost::container::basic_string<CharT,Traits,Alloc1>
385
- , ::boost::container::basic_string<CharT,Traits,Alloc2>
490
+ template<class Char, class Traits, class Alloc1, class Alloc2>
491
+ struct deduce_char_traits< Char
492
+ , boost::container::basic_string< Char, Traits, Alloc1 >
493
+ , boost::container::basic_string< Char, Traits, Alloc2 >
386
494
  >
387
495
  {
388
496
  typedef Traits type;
389
497
  };
390
498
 
391
- template<class CharT, class Traits, class Alloc1, class Alloc2>
392
- struct deduce_char_traits< CharT
393
- , ::boost::container::basic_string<CharT,Traits,Alloc1>
394
- , ::std::basic_string<CharT,Traits,Alloc2>
499
+ template < class Char, class Traits, class Alloc1, class Alloc2 >
500
+ struct deduce_char_traits< Char
501
+ , boost::container::basic_string< Char, Traits, Alloc1 >
502
+ , std::basic_string< Char, Traits, Alloc2 >
395
503
  >
396
504
  {
397
505
  typedef Traits type;
398
506
  };
399
507
 
400
- template<class CharT, class Traits, class Alloc1, class Alloc2>
401
- struct deduce_char_traits< CharT
402
- , ::std::basic_string<CharT,Traits,Alloc1>
403
- , ::boost::container::basic_string<CharT,Traits,Alloc2>
508
+ template < class Char, class Traits, class Alloc1, class Alloc2 >
509
+ struct deduce_char_traits< Char
510
+ , std::basic_string< Char, Traits, Alloc1 >
511
+ , boost::container::basic_string< Char, Traits, Alloc2 >
404
512
  >
405
513
  {
406
514
  typedef Traits type;
407
515
  };
408
516
  }
409
517
 
518
+ namespace detail // array_to_pointer_decay<T>
519
+ {
520
+ template<class T>
521
+ struct array_to_pointer_decay
522
+ {
523
+ typedef T type;
524
+ };
525
+
526
+ template<class T, std::size_t N>
527
+ struct array_to_pointer_decay<T[N]>
528
+ {
529
+ typedef const T * type;
530
+ };
531
+ }
532
+
533
+ namespace detail // is_this_float_conversion_optimized<Float, Char>
534
+ {
535
+ // this metafunction evaluates to true, if we have optimized comnversion
536
+ // from Float type to Char array.
537
+ // Must be in sync with lexical_stream_limited_src<Char, ...>::shl_real_type(...)
538
+ template <typename Float, typename Char>
539
+ struct is_this_float_conversion_optimized
540
+ {
541
+ typedef boost::type_traits::ice_and<
542
+ boost::is_float<Float>::value,
543
+ #if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_SWPRINTF) && !defined(__MINGW32__)
544
+ boost::type_traits::ice_or<
545
+ boost::type_traits::ice_eq<sizeof(Char), sizeof(char) >::value,
546
+ boost::is_same<Char, wchar_t>::value
547
+ >::value
548
+ #else
549
+ boost::type_traits::ice_eq<sizeof(Char), sizeof(char) >::value
550
+ #endif
551
+ > result_type;
552
+
553
+ BOOST_STATIC_CONSTANT(bool, value = (result_type::value) );
554
+ };
555
+ }
556
+
410
557
  namespace detail // lcast_src_length
411
558
  {
412
559
  // Return max. length of string representation of Source;
@@ -466,6 +613,10 @@ namespace boost {
466
613
  BOOST_LCAST_DEF(unsigned __int64)
467
614
  BOOST_LCAST_DEF( __int64)
468
615
  #endif
616
+ #ifdef BOOST_LCAST_HAS_INT128
617
+ BOOST_LCAST_DEF(boost::int128_type)
618
+ BOOST_LCAST_DEF(boost::uint128_type)
619
+ #endif
469
620
 
470
621
  #undef BOOST_LCAST_DEF
471
622
 
@@ -516,9 +667,67 @@ namespace boost {
516
667
  #endif // #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION
517
668
  }
518
669
 
670
+ namespace detail // lexical_cast_stream_traits<Source, Target>
671
+ {
672
+ template <class Source, class Target>
673
+ struct lexical_cast_stream_traits {
674
+ typedef BOOST_DEDUCED_TYPENAME boost::detail::array_to_pointer_decay<Source>::type src;
675
+ typedef BOOST_DEDUCED_TYPENAME boost::remove_cv<src>::type no_cv_src;
676
+
677
+ typedef boost::detail::deduce_source_char<no_cv_src> deduce_src_char_metafunc;
678
+ typedef BOOST_DEDUCED_TYPENAME deduce_src_char_metafunc::type src_char_t;
679
+ typedef BOOST_DEDUCED_TYPENAME boost::detail::deduce_target_char<Target>::type target_char_t;
680
+
681
+ typedef BOOST_DEDUCED_TYPENAME boost::detail::widest_char<
682
+ target_char_t, src_char_t
683
+ >::type char_type;
684
+
685
+ #if !defined(BOOST_NO_CXX11_CHAR16_T) && defined(BOOST_NO_CXX11_UNICODE_LITERALS)
686
+ BOOST_STATIC_ASSERT_MSG(( !boost::is_same<char16_t, src_char_t>::value
687
+ && !boost::is_same<char16_t, target_char_t>::value),
688
+ "Your compiler does not have full support for char16_t" );
689
+ #endif
690
+ #if !defined(BOOST_NO_CXX11_CHAR32_T) && defined(BOOST_NO_CXX11_UNICODE_LITERALS)
691
+ BOOST_STATIC_ASSERT_MSG(( !boost::is_same<char32_t, src_char_t>::value
692
+ && !boost::is_same<char32_t, target_char_t>::value),
693
+ "Your compiler does not have full support for char32_t" );
694
+ #endif
695
+
696
+ typedef BOOST_DEDUCED_TYPENAME boost::detail::deduce_char_traits<
697
+ char_type, Target, no_cv_src
698
+ >::type traits;
699
+
700
+ typedef boost::type_traits::ice_and<
701
+ boost::is_same<char, src_char_t>::value, // source is not a wide character based type
702
+ boost::type_traits::ice_ne<sizeof(char), sizeof(target_char_t) >::value, // target type is based on wide character
703
+ boost::type_traits::ice_not<
704
+ boost::detail::is_char_or_wchar<no_cv_src>::value // single character widening is optimized
705
+ >::value // and does not requires stringbuffer
706
+ > is_string_widening_required_t;
707
+
708
+ typedef boost::type_traits::ice_not< boost::type_traits::ice_or<
709
+ boost::is_integral<no_cv_src>::value,
710
+ boost::detail::is_this_float_conversion_optimized<no_cv_src, char_type >::value,
711
+ boost::detail::is_char_or_wchar<
712
+ BOOST_DEDUCED_TYPENAME deduce_src_char_metafunc::stage1_type // if we did not get character type at stage1
713
+ >::value // then we have no optimization for that type
714
+ >::value > is_source_input_not_optimized_t;
715
+
716
+ // If we have an optimized conversion for
717
+ // Source, we do not need to construct stringbuf.
718
+ BOOST_STATIC_CONSTANT(bool, requires_stringbuf =
719
+ (boost::type_traits::ice_or<
720
+ is_string_widening_required_t::value, is_source_input_not_optimized_t::value
721
+ >::value)
722
+ );
723
+
724
+ typedef boost::detail::lcast_src_length<no_cv_src> len_t;
725
+ };
726
+ }
727
+
519
728
  namespace detail // '0', '+' and '-' constants
520
729
  {
521
- template<typename CharT> struct lcast_char_constants;
730
+ template < typename Char > struct lcast_char_constants;
522
731
 
523
732
  template<>
524
733
  struct lcast_char_constants<char>
@@ -544,7 +753,7 @@ namespace boost {
544
753
  };
545
754
  #endif
546
755
 
547
- #if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS)
756
+ #if !defined(BOOST_NO_CXX11_CHAR16_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS)
548
757
  template<>
549
758
  struct lcast_char_constants<char16_t>
550
759
  {
@@ -557,7 +766,7 @@ namespace boost {
557
766
  };
558
767
  #endif
559
768
 
560
- #if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS)
769
+ #if !defined(BOOST_NO_CXX11_CHAR32_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS)
561
770
  template<>
562
771
  struct lcast_char_constants<char32_t>
563
772
  {
@@ -573,26 +782,15 @@ namespace boost {
573
782
 
574
783
  namespace detail // lcast_to_unsigned
575
784
  {
576
- #if (defined _MSC_VER)
577
- # pragma warning( push )
578
- // C4146: unary minus operator applied to unsigned type, result still unsigned
579
- # pragma warning( disable : 4146 )
580
- #elif defined( __BORLANDC__ )
581
- # pragma option push -w-8041
582
- #endif
583
785
  template<class T>
584
786
  inline
585
787
  BOOST_DEDUCED_TYPENAME make_unsigned<T>::type lcast_to_unsigned(T value) BOOST_NOEXCEPT
586
788
  {
587
- typedef BOOST_DEDUCED_TYPENAME make_unsigned<T>::type result_type;
588
- const result_type uvalue = static_cast<result_type>(value);
589
- return value < 0 ? -uvalue : uvalue;
789
+ typedef BOOST_DEDUCED_TYPENAME boost::make_unsigned<T>::type result_type;
790
+ return static_cast<result_type>(
791
+ value < 0 ? 0u - static_cast<result_type>(value) : value
792
+ );
590
793
  }
591
- #if (defined _MSC_VER)
592
- # pragma warning( pop )
593
- #elif defined( __BORLANDC__ )
594
- # pragma option pop
595
- #endif
596
794
  }
597
795
 
598
796
  namespace detail // lcast_put_unsigned
@@ -641,7 +839,7 @@ namespace boost {
641
839
  if(group < grouping_size)
642
840
  {
643
841
  char const grp_size = grouping[group];
644
- last_grp_size = grp_size <= 0 ? CHAR_MAX : grp_size;
842
+ last_grp_size = grp_size <= 0 ? static_cast<char>(CHAR_MAX) : grp_size;
645
843
  }
646
844
 
647
845
  left = last_grp_size;
@@ -682,14 +880,13 @@ namespace boost {
682
880
  #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
683
881
  BOOST_STATIC_ASSERT(!std::numeric_limits<T>::is_signed);
684
882
  #endif
685
- typedef typename Traits::int_type int_type;
686
883
  CharT const czero = lcast_char_constants<CharT>::zero;
687
884
  --end;
688
885
  value = 0;
689
886
 
690
887
  if (begin > end || *end < czero || *end >= czero + 10)
691
888
  return false;
692
- value = *end - czero;
889
+ value = static_cast<T>(*end - czero);
693
890
  --end;
694
891
  T multiplier = 1;
695
892
  bool multiplier_overflowed = false;
@@ -709,17 +906,17 @@ namespace boost {
709
906
  {
710
907
  unsigned char current_grouping = 0;
711
908
  CharT const thousands_sep = np.thousands_sep();
712
- char remained = grouping[current_grouping] - 1;
909
+ char remained = static_cast<char>(grouping[current_grouping] - 1);
713
910
  bool shall_we_return = true;
714
911
 
715
912
  for(;end>=begin; --end)
716
913
  {
717
914
  if (remained) {
718
- T const multiplier_10 = multiplier * 10;
915
+ T const multiplier_10 = static_cast<T>(multiplier * 10);
719
916
  if (multiplier_10 / 10 != multiplier) multiplier_overflowed = true;
720
917
 
721
- T const dig_value = *end - czero;
722
- T const new_sub_value = multiplier_10 * dig_value;
918
+ T const dig_value = static_cast<T>(*end - czero);
919
+ T const new_sub_value = static_cast<T>(multiplier_10 * dig_value);
723
920
 
724
921
  if (*end < czero || *end >= czero + 10
725
922
  /* detecting overflow */
@@ -729,8 +926,8 @@ namespace boost {
729
926
  )
730
927
  return false;
731
928
 
732
- value += new_sub_value;
733
- multiplier *= 10;
929
+ value = static_cast<T>(value + new_sub_value);
930
+ multiplier = static_cast<T>(multiplier * 10);
734
931
  --remained;
735
932
  } else {
736
933
  if ( !Traits::eq(*end, thousands_sep) ) //|| begin == end ) return false;
@@ -763,11 +960,11 @@ namespace boost {
763
960
  {
764
961
  while ( begin <= end )
765
962
  {
766
- T const multiplier_10 = multiplier * 10;
963
+ T const multiplier_10 = static_cast<T>(multiplier * 10);
767
964
  if (multiplier_10 / 10 != multiplier) multiplier_overflowed = true;
768
965
 
769
- T const dig_value = *end - czero;
770
- T const new_sub_value = multiplier_10 * dig_value;
966
+ T const dig_value = static_cast<T>(*end - czero);
967
+ T const new_sub_value = static_cast<T>(multiplier_10 * dig_value);
771
968
 
772
969
  if (*end < czero || *end >= czero + 10
773
970
  /* detecting overflow */
@@ -777,8 +974,8 @@ namespace boost {
777
974
  )
778
975
  return false;
779
976
 
780
- value += new_sub_value;
781
- multiplier *= 10;
977
+ value = static_cast<T>(value + new_sub_value);
978
+ multiplier = static_cast<T>(multiplier * 10);
782
979
  --end;
783
980
  }
784
981
  }
@@ -907,7 +1104,7 @@ namespace boost {
907
1104
  }
908
1105
 
909
1106
  #endif
910
- #if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS)
1107
+ #if !defined(BOOST_NO_CXX11_CHAR16_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS)
911
1108
  template <class T>
912
1109
  bool parse_inf_nan(const char16_t* begin, const char16_t* end, T& value) BOOST_NOEXCEPT
913
1110
  {
@@ -923,7 +1120,7 @@ namespace boost {
923
1120
  return put_inf_nan_impl(begin, end, value, u"nan", u"infinity");
924
1121
  }
925
1122
  #endif
926
- #if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS)
1123
+ #if !defined(BOOST_NO_CXX11_CHAR32_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS)
927
1124
  template <class T>
928
1125
  bool parse_inf_nan(const char32_t* begin, const char32_t* end, T& value) BOOST_NOEXCEPT
929
1126
  {
@@ -959,6 +1156,12 @@ namespace boost {
959
1156
 
960
1157
  namespace detail // lcast_ret_float
961
1158
  {
1159
+
1160
+ // Silence buggy MS warnings like C4244: '+=' : conversion from 'int' to 'unsigned short', possible loss of data
1161
+ #if defined(_MSC_VER) && (_MSC_VER == 1400)
1162
+ # pragma warning(push)
1163
+ # pragma warning(disable:4244)
1164
+ #endif
962
1165
  template <class T>
963
1166
  struct mantissa_holder_type
964
1167
  {
@@ -969,15 +1172,19 @@ namespace boost {
969
1172
  struct mantissa_holder_type<float>
970
1173
  {
971
1174
  typedef unsigned int type;
1175
+ typedef double wide_result_t;
972
1176
  };
973
1177
 
974
1178
  template <>
975
1179
  struct mantissa_holder_type<double>
976
1180
  {
1181
+ #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
1182
+ typedef long double wide_result_t;
977
1183
  #if defined(BOOST_HAS_LONG_LONG)
978
1184
  typedef boost::ulong_long_type type;
979
1185
  #elif defined(BOOST_HAS_MS_INT64)
980
1186
  typedef unsigned __int64 type;
1187
+ #endif
981
1188
  #endif
982
1189
  };
983
1190
 
@@ -995,7 +1202,7 @@ namespace boost {
995
1202
  : np.grouping()
996
1203
  );
997
1204
  std::string::size_type const grouping_size = grouping.size();
998
- CharT const thousands_sep = grouping_size ? np.thousands_sep() : 0;
1205
+ CharT const thousands_sep = static_cast<CharT>(grouping_size ? np.thousands_sep() : 0);
999
1206
  CharT const decimal_point = np.decimal_point();
1000
1207
  bool found_grouping = false;
1001
1208
  std::string::size_type last_grouping_pos = grouping_size - 1;
@@ -1015,6 +1222,7 @@ namespace boost {
1015
1222
 
1016
1223
  typedef typename Traits::int_type int_type;
1017
1224
  typedef BOOST_DEDUCED_TYPENAME mantissa_holder_type<T>::type mantissa_type;
1225
+ typedef BOOST_DEDUCED_TYPENAME mantissa_holder_type<T>::wide_result_t wide_result_t;
1018
1226
  int_type const zero = Traits::to_int_type(czero);
1019
1227
  if (begin == end) return false;
1020
1228
 
@@ -1193,32 +1401,110 @@ namespace boost {
1193
1401
  /* We need a more accurate algorithm... We can not use current algorithm
1194
1402
  * with long doubles (and with doubles if sizeof(double)==sizeof(long double)).
1195
1403
  */
1196
- long double result = std::pow(10.0L, pow_of_10) * mantissa;
1404
+ const wide_result_t result = std::pow(static_cast<wide_result_t>(10.0), pow_of_10) * mantissa;
1197
1405
  value = static_cast<T>( has_minus ? (boost::math::changesign)(result) : result);
1198
1406
 
1199
1407
  if ( (boost::math::isinf)(value) || (boost::math::isnan)(value) ) return false;
1200
1408
 
1201
1409
  return true;
1202
1410
  }
1411
+ // Unsilence buggy MS warnings like C4244: '+=' : conversion from 'int' to 'unsigned short', possible loss of data
1412
+ #if defined(_MSC_VER) && (_MSC_VER == 1400)
1413
+ # pragma warning(pop)
1414
+ #endif
1203
1415
  }
1204
1416
 
1205
- namespace detail // stl_buf_unlocker
1417
+ namespace detail // parser_buf
1206
1418
  {
1207
- template< class BufferType, class CharT >
1208
- class stl_buf_unlocker: public BufferType{
1419
+ //
1420
+ // class parser_buf:
1421
+ // acts as a stream buffer which wraps around a pair of pointers
1422
+ //
1423
+ // This class is copied (and slightly changed) from
1424
+ // boost/regex/v4/cpp_regex_traits.hpp
1425
+ // Thanks John Maddock for it! (previous version had some
1426
+ // problems with libc++ and some other STL implementations)
1427
+ template <class BufferType, class charT>
1428
+ class parser_buf : public BufferType {
1429
+ typedef BufferType base_type;
1430
+ typedef typename base_type::int_type int_type;
1431
+ typedef typename base_type::char_type char_type;
1432
+ typedef typename base_type::pos_type pos_type;
1433
+ typedef ::std::streamsize streamsize;
1434
+ typedef typename base_type::off_type off_type;
1435
+
1209
1436
  public:
1210
- typedef BufferType base_class;
1437
+ parser_buf() : base_type() { setbuf(0, 0); }
1438
+ const charT* getnext() { return this->gptr(); }
1211
1439
  #ifndef BOOST_NO_USING_TEMPLATE
1212
- using base_class::pptr;
1213
- using base_class::pbase;
1214
- using base_class::setg;
1215
- using base_class::setp;
1440
+ using base_type::pptr;
1441
+ using base_type::pbase;
1216
1442
  #else
1217
- CharT* pptr() const { return base_class::pptr(); }
1218
- CharT* pbase() const { return base_class::pbase(); }
1219
- void setg(CharT* gbeg, CharT* gnext, CharT* gend){ return base_class::setg(gbeg, gnext, gend); }
1220
- void setp(CharT* pbeg, CharT* pend) { return setp(pbeg, pend); }
1443
+ charT* pptr() const { return base_type::pptr(); }
1444
+ charT* pbase() const { return base_type::pbase(); }
1445
+ #endif
1446
+ base_type* setbuf(char_type* s, streamsize n) {
1447
+ this->setg(s, s, s + n);
1448
+ return this;
1449
+ }
1450
+
1451
+ pos_type seekpos(pos_type sp, ::std::ios_base::openmode which) {
1452
+ if(which & ::std::ios_base::out)
1453
+ return pos_type(off_type(-1));
1454
+ off_type size = static_cast<off_type>(this->egptr() - this->eback());
1455
+ charT* g = this->eback();
1456
+ if(off_type(sp) <= size)
1457
+ {
1458
+ this->setg(g, g + off_type(sp), g + size);
1459
+ }
1460
+ return pos_type(off_type(-1));
1461
+ }
1462
+
1463
+ pos_type seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which) {
1464
+ typedef typename boost::int_t<sizeof(way) * CHAR_BIT>::least cast_type;
1465
+
1466
+ if(which & ::std::ios_base::out)
1467
+ return pos_type(off_type(-1));
1468
+ std::ptrdiff_t size = this->egptr() - this->eback();
1469
+ std::ptrdiff_t pos = this->gptr() - this->eback();
1470
+ charT* g = this->eback();
1471
+ switch(static_cast<cast_type>(way))
1472
+ {
1473
+ case ::std::ios_base::beg:
1474
+ if((off < 0) || (off > size))
1475
+ return pos_type(off_type(-1));
1476
+ else
1477
+ this->setg(g, g + off, g + size);
1478
+ break;
1479
+ case ::std::ios_base::end:
1480
+ if((off < 0) || (off > size))
1481
+ return pos_type(off_type(-1));
1482
+ else
1483
+ this->setg(g, g + size - off, g + size);
1484
+ break;
1485
+ case ::std::ios_base::cur:
1486
+ {
1487
+ std::ptrdiff_t newpos = static_cast<std::ptrdiff_t>(pos + off);
1488
+ if((newpos < 0) || (newpos > size))
1489
+ return pos_type(off_type(-1));
1490
+ else
1491
+ this->setg(g, g + newpos, g + size);
1492
+ break;
1493
+ }
1494
+ default: ;
1495
+ }
1496
+ #ifdef BOOST_MSVC
1497
+ #pragma warning(push)
1498
+ #pragma warning(disable:4244)
1499
+ #endif
1500
+ return static_cast<pos_type>(this->gptr() - this->eback());
1501
+ #ifdef BOOST_MSVC
1502
+ #pragma warning(pop)
1221
1503
  #endif
1504
+ }
1505
+ private:
1506
+ parser_buf& operator=(const parser_buf&);
1507
+ parser_buf(const parser_buf&);
1222
1508
  };
1223
1509
  }
1224
1510
 
@@ -1239,15 +1525,14 @@ namespace boost {
1239
1525
 
1240
1526
  #if defined(BOOST_NO_STRINGSTREAM)
1241
1527
  typedef std::ostrstream out_stream_t;
1242
- typedef stl_buf_unlocker<std::strstreambuf, char> unlocked_but_t;
1243
1528
  #elif defined(BOOST_NO_STD_LOCALE)
1244
1529
  typedef std::ostringstream out_stream_t;
1245
- typedef stl_buf_unlocker<std::stringbuf, char> unlocked_but_t;
1530
+ typedef parser_buf<std::streambuf, char> buffer_t;
1246
1531
  #else
1247
- typedef std::basic_ostringstream<CharT, Traits> out_stream_t;
1248
- typedef stl_buf_unlocker<std::basic_stringbuf<CharT, Traits>, CharT> unlocked_but_t;
1532
+ typedef std::basic_ostringstream<CharT, Traits> out_stream_t;
1533
+ typedef parser_buf<std::basic_streambuf<CharT, Traits>, CharT> buffer_t;
1249
1534
  #endif
1250
- typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c<
1535
+ typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c<
1251
1536
  RequiresStringbuffer,
1252
1537
  out_stream_t,
1253
1538
  do_not_construct_out_stream_t
@@ -1259,7 +1544,7 @@ namespace boost {
1259
1544
  deduced_out_stream_t out_stream;
1260
1545
 
1261
1546
  public:
1262
- lexical_stream_limited_src(CharT* sta, CharT* fin)
1547
+ lexical_stream_limited_src(CharT* sta, CharT* fin) BOOST_NOEXCEPT
1263
1548
  : start(sta)
1264
1549
  , finish(fin)
1265
1550
  {}
@@ -1288,7 +1573,7 @@ namespace boost {
1288
1573
  std::locale loc;
1289
1574
  CharT const w = BOOST_USE_FACET(std::ctype<CharT>, loc).widen(ch);
1290
1575
  #else
1291
- CharT const w = ch;
1576
+ CharT const w = static_cast<CharT>(ch);
1292
1577
  #endif
1293
1578
  Traits::assign(*start, w);
1294
1579
  finish = start + 1;
@@ -1328,8 +1613,9 @@ namespace boost {
1328
1613
  BOOST_STATIC_ASSERT((boost::is_same<char, CharT>::value));
1329
1614
  #endif
1330
1615
  bool const result = !(out_stream << input).fail();
1331
- const unlocked_but_t* const p
1332
- = static_cast<unlocked_but_t*>(out_stream.rdbuf()) ;
1616
+ const buffer_t* const p = static_cast<buffer_t*>(
1617
+ static_cast<std::basic_streambuf<CharT, Traits>*>(out_stream.rdbuf())
1618
+ );
1333
1619
  start = p->pbase();
1334
1620
  finish = p->pptr();
1335
1621
  return result;
@@ -1439,7 +1725,7 @@ namespace boost {
1439
1725
  }
1440
1726
 
1441
1727
  template<class Alloc>
1442
- bool operator<<(::boost::container::basic_string<CharT,Traits,Alloc> const& str) BOOST_NOEXCEPT
1728
+ bool operator<<(boost::container::basic_string<CharT,Traits,Alloc> const& str) BOOST_NOEXCEPT
1443
1729
  {
1444
1730
  start = const_cast<CharT*>(str.data());
1445
1731
  finish = start + str.length();
@@ -1510,12 +1796,12 @@ namespace boost {
1510
1796
  bool operator<<(wchar_t ch) { return shl_char(ch); }
1511
1797
  #endif
1512
1798
  #endif
1513
- #if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS)
1799
+ #if !defined(BOOST_NO_CXX11_CHAR16_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS)
1514
1800
  bool operator<<(char16_t ch) { return shl_char(ch); }
1515
1801
  bool operator<<(char16_t * str) { return shl_char_array(str); }
1516
1802
  bool operator<<(char16_t const * str) { return shl_char_array(str); }
1517
1803
  #endif
1518
- #if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS)
1804
+ #if !defined(BOOST_NO_CXX11_CHAR32_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS)
1519
1805
  bool operator<<(char32_t ch) { return shl_char(ch); }
1520
1806
  bool operator<<(char32_t * str) { return shl_char_array(str); }
1521
1807
  bool operator<<(char32_t const * str) { return shl_char_array(str); }
@@ -1540,6 +1826,12 @@ namespace boost {
1540
1826
  bool operator<<(unsigned __int64 n) { start = lcast_put_unsigned<Traits>(n, finish); return true; }
1541
1827
  bool operator<<( __int64 n) { return shl_signed(n); }
1542
1828
  #endif
1829
+
1830
+ #ifdef BOOST_LCAST_HAS_INT128
1831
+ bool operator<<(const boost::uint128_type& n) { start = lcast_put_unsigned<Traits>(n, finish); return true; }
1832
+ bool operator<<(const boost::int128_type& n) { return shl_signed(n); }
1833
+ #endif
1834
+
1543
1835
  bool operator<<(float val) { return shl_real_type(val, start, finish); }
1544
1836
  bool operator<<(double val) { return shl_real_type(val, start, finish); }
1545
1837
  bool operator<<(long double val) {
@@ -1574,10 +1866,13 @@ namespace boost {
1574
1866
  bool operator<<(boost::array<const signed char, N> const& input) BOOST_NOEXCEPT
1575
1867
  { return ((*this) << reinterpret_cast<boost::array<const char, N> const& >(input)); }
1576
1868
 
1577
- #if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
1869
+ #ifndef BOOST_NO_CXX11_HDR_ARRAY
1578
1870
  template <std::size_t N>
1579
1871
  bool operator<<(std::array<CharT, N> const& input) BOOST_NOEXCEPT
1580
- { return shl_char_array_limited(input.begin(), N); }
1872
+ {
1873
+ if (input.size()) return shl_char_array_limited(&input[0], N);
1874
+ else return true;
1875
+ }
1581
1876
 
1582
1877
  template <std::size_t N>
1583
1878
  bool operator<<(std::array<unsigned char, N> const& input) BOOST_NOEXCEPT
@@ -1589,7 +1884,10 @@ namespace boost {
1589
1884
 
1590
1885
  template <std::size_t N>
1591
1886
  bool operator<<(std::array<const CharT, N> const& input) BOOST_NOEXCEPT
1592
- { return shl_char_array_limited(input.begin(), N); }
1887
+ {
1888
+ if (input.size()) return shl_char_array_limited(&input[0], N);
1889
+ else return true;
1890
+ }
1593
1891
 
1594
1892
  template <std::size_t N>
1595
1893
  bool operator<<(std::array<const unsigned char, N> const& input) BOOST_NOEXCEPT
@@ -1598,7 +1896,7 @@ namespace boost {
1598
1896
  template <std::size_t N>
1599
1897
  bool operator<<(std::array<const signed char, N> const& input) BOOST_NOEXCEPT
1600
1898
  { return ((*this) << reinterpret_cast<boost::array<const char, N> const& >(input)); }
1601
- #endif // !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
1899
+ #endif
1602
1900
 
1603
1901
  template <class InStreamable>
1604
1902
  bool operator<<(const InStreamable& input) { return shl_input_streamable(input); }
@@ -1625,19 +1923,11 @@ namespace boost {
1625
1923
  }
1626
1924
 
1627
1925
  bool const succeed = lcast_ret_unsigned<Traits>(output, start, finish);
1628
- #if (defined _MSC_VER)
1629
- # pragma warning( push )
1630
- // C4146: unary minus operator applied to unsigned type, result still unsigned
1631
- # pragma warning( disable : 4146 )
1632
- #elif defined( __BORLANDC__ )
1633
- # pragma option push -w-8041
1634
- #endif
1635
- if (has_minus) output = static_cast<Type>(-output);
1636
- #if (defined _MSC_VER)
1637
- # pragma warning( pop )
1638
- #elif defined( __BORLANDC__ )
1639
- # pragma option pop
1640
- #endif
1926
+
1927
+ if (has_minus) {
1928
+ output = static_cast<Type>(0u - output);
1929
+ }
1930
+
1641
1931
  return succeed;
1642
1932
  }
1643
1933
 
@@ -1663,21 +1953,9 @@ namespace boost {
1663
1953
 
1664
1954
  bool succeed = lcast_ret_unsigned<Traits>(out_tmp, start, finish);
1665
1955
  if (has_minus) {
1666
- #if (defined _MSC_VER)
1667
- # pragma warning( push )
1668
- // C4146: unary minus operator applied to unsigned type, result still unsigned
1669
- # pragma warning( disable : 4146 )
1670
- #elif defined( __BORLANDC__ )
1671
- # pragma option push -w-8041
1672
- #endif
1673
- utype const comp_val = static_cast<utype>(-(std::numeric_limits<Type>::min)());
1956
+ utype const comp_val = (static_cast<utype>(1) << std::numeric_limits<Type>::digits);
1674
1957
  succeed = succeed && out_tmp<=comp_val;
1675
- output = -out_tmp;
1676
- #if (defined _MSC_VER)
1677
- # pragma warning( pop )
1678
- #elif defined( __BORLANDC__ )
1679
- # pragma option pop
1680
- #endif
1958
+ output = static_cast<Type>(0u - out_tmp);
1681
1959
  } else {
1682
1960
  utype const comp_val = static_cast<utype>((std::numeric_limits<Type>::max)());
1683
1961
  succeed = succeed && out_tmp<=comp_val;
@@ -1689,35 +1967,34 @@ namespace boost {
1689
1967
  template<typename InputStreamable>
1690
1968
  bool shr_using_base_class(InputStreamable& output)
1691
1969
  {
1692
- #if (defined _MSC_VER)
1693
- # pragma warning( push )
1694
- // conditional expression is constant
1695
- # pragma warning( disable : 4127 )
1696
- #endif
1697
- if(is_pointer<InputStreamable>::value)
1698
- return false;
1970
+ BOOST_STATIC_ASSERT_MSG(
1971
+ (!boost::is_pointer<InputStreamable>::value),
1972
+ "boost::lexical_cast can not convert to pointers"
1973
+ );
1699
1974
 
1700
1975
  #if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_LOCALE)
1701
- // If you have compilation error at this point, than your STL library
1702
- // unsupports such conversions. Try updating it.
1703
- BOOST_STATIC_ASSERT((boost::is_same<char, CharT>::value));
1976
+ BOOST_STATIC_ASSERT_MSG((boost::is_same<char, CharT>::value),
1977
+ "boost::lexical_cast can not convert, because your STL library does not "
1978
+ "support such conversions. Try updating it."
1979
+ );
1704
1980
  #endif
1705
1981
 
1706
1982
  #if defined(BOOST_NO_STRINGSTREAM)
1707
1983
  std::istrstream stream(start, finish - start);
1708
- #elif defined(BOOST_NO_STD_LOCALE)
1709
- std::istringstream stream;
1710
1984
  #else
1711
- std::basic_istringstream<CharT, Traits> stream;
1712
- #endif
1713
- static_cast<unlocked_but_t*>(stream.rdbuf())
1714
- ->setg(start, start, finish);
1985
+
1986
+ buffer_t buf;
1987
+ buf.setbuf(start, finish - start);
1988
+ #if defined(BOOST_NO_STD_LOCALE)
1989
+ std::istream stream(&buf);
1990
+ #else
1991
+ std::basic_istream<CharT, Traits> stream(&buf);
1992
+ #endif // BOOST_NO_STD_LOCALE
1993
+ #endif // BOOST_NO_STRINGSTREAM
1715
1994
 
1716
1995
  stream.unsetf(std::ios::skipws);
1717
1996
  lcast_set_precision(stream, static_cast<InputStreamable*>(0));
1718
- #if (defined _MSC_VER)
1719
- # pragma warning( pop )
1720
- #endif
1997
+
1721
1998
  return stream >> output &&
1722
1999
  stream.get() ==
1723
2000
  #if defined(__GNUC__) && (__GNUC__<3) && defined(BOOST_NO_STD_WSTRING)
@@ -1747,7 +2024,7 @@ namespace boost {
1747
2024
  }
1748
2025
 
1749
2026
  /************************************ OPERATORS >> ( ... ) ********************************/
1750
- public:
2027
+ public:
1751
2028
  bool operator>>(unsigned short& output) { return shr_unsigned(output); }
1752
2029
  bool operator>>(unsigned int& output) { return shr_unsigned(output); }
1753
2030
  bool operator>>(unsigned long int& output) { return shr_unsigned(output); }
@@ -1761,23 +2038,29 @@ namespace boost {
1761
2038
  bool operator>>(unsigned __int64& output) { return shr_unsigned(output); }
1762
2039
  bool operator>>(__int64& output) { return shr_signed(output); }
1763
2040
  #endif
2041
+
2042
+ #ifdef BOOST_LCAST_HAS_INT128
2043
+ bool operator>>(boost::uint128_type& output) { return shr_unsigned(output); }
2044
+ bool operator>>(boost::int128_type& output) { return shr_signed(output); }
2045
+ #endif
2046
+
1764
2047
  bool operator>>(char& output) { return shr_xchar(output); }
1765
2048
  bool operator>>(unsigned char& output) { return shr_xchar(output); }
1766
2049
  bool operator>>(signed char& output) { return shr_xchar(output); }
1767
2050
  #if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T)
1768
2051
  bool operator>>(wchar_t& output) { return shr_xchar(output); }
1769
2052
  #endif
1770
- #if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS)
2053
+ #if !defined(BOOST_NO_CXX11_CHAR16_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS)
1771
2054
  bool operator>>(char16_t& output) { return shr_xchar(output); }
1772
2055
  #endif
1773
- #if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS)
2056
+ #if !defined(BOOST_NO_CXX11_CHAR32_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS)
1774
2057
  bool operator>>(char32_t& output) { return shr_xchar(output); }
1775
2058
  #endif
1776
2059
  template<class Alloc>
1777
2060
  bool operator>>(std::basic_string<CharT,Traits,Alloc>& str) { str.assign(start, finish); return true; }
1778
2061
 
1779
2062
  template<class Alloc>
1780
- bool operator>>(::boost::container::basic_string<CharT,Traits,Alloc>& str) { str.assign(start, finish); return true; }
2063
+ bool operator>>(boost::container::basic_string<CharT,Traits,Alloc>& str) { str.assign(start, finish); return true; }
1781
2064
 
1782
2065
 
1783
2066
  private:
@@ -1790,8 +2073,8 @@ namespace boost {
1790
2073
  return false;
1791
2074
  }
1792
2075
 
1793
- memcpy(output.begin(), start, size * sizeof(CharT));
1794
- *(output.begin() + size) = Traits::to_char_type(0);
2076
+ memcpy(&output[0], start, size * sizeof(CharT));
2077
+ output[size] = Traits::to_char_type(0);
1795
2078
  return true;
1796
2079
  }
1797
2080
 
@@ -1815,7 +2098,7 @@ namespace boost {
1815
2098
  return ((*this) >> reinterpret_cast<boost::array<char, N>& >(output));
1816
2099
  }
1817
2100
 
1818
- #if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
2101
+ #ifndef BOOST_NO_CXX11_HDR_ARRAY
1819
2102
  template <std::size_t N>
1820
2103
  bool operator>>(std::array<CharT, N>& output) BOOST_NOEXCEPT
1821
2104
  {
@@ -1829,11 +2112,11 @@ namespace boost {
1829
2112
  }
1830
2113
 
1831
2114
  template <std::size_t N>
1832
- bool operator>>(std::array<signed char, N>& in)
2115
+ bool operator>>(std::array<signed char, N>& output)
1833
2116
  {
1834
2117
  return ((*this) >> reinterpret_cast<std::array<char, N>& >(output));
1835
2118
  }
1836
- #endif // !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
2119
+ #endif
1837
2120
 
1838
2121
 
1839
2122
  /*
@@ -1916,10 +2199,10 @@ namespace boost {
1916
2199
  * double, because it will give a big precision loss.
1917
2200
  * */
1918
2201
  boost::mpl::if_c<
1919
- #if defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)
1920
- ::boost::type_traits::ice_eq< sizeof(double), sizeof(long double) >::value,
2202
+ #if (defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)) && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
2203
+ boost::type_traits::ice_eq< sizeof(double), sizeof(long double) >::value,
1921
2204
  #else
1922
- 0
2205
+ 1,
1923
2206
  #endif
1924
2207
  int,
1925
2208
  char
@@ -1943,18 +2226,6 @@ namespace boost {
1943
2226
 
1944
2227
  namespace detail
1945
2228
  {
1946
- template<class T>
1947
- struct array_to_pointer_decay
1948
- {
1949
- typedef T type;
1950
- };
1951
-
1952
- template<class T, std::size_t N>
1953
- struct array_to_pointer_decay<T[N]>
1954
- {
1955
- typedef const T * type;
1956
- };
1957
-
1958
2229
  template<typename T>
1959
2230
  struct is_stdstring
1960
2231
  {
@@ -1968,7 +2239,7 @@ namespace boost {
1968
2239
  };
1969
2240
 
1970
2241
  template<typename CharT, typename Traits, typename Alloc>
1971
- struct is_stdstring< ::boost::container::basic_string<CharT, Traits, Alloc> >
2242
+ struct is_stdstring< boost::container::basic_string<CharT, Traits, Alloc> >
1972
2243
  {
1973
2244
  BOOST_STATIC_CONSTANT(bool, value = true );
1974
2245
  };
@@ -1978,13 +2249,13 @@ namespace boost {
1978
2249
  {
1979
2250
  BOOST_STATIC_CONSTANT(bool, value =
1980
2251
  (
1981
- ::boost::type_traits::ice_and<
1982
- ::boost::is_arithmetic<Source>::value,
1983
- ::boost::is_arithmetic<Target>::value,
1984
- ::boost::type_traits::ice_not<
2252
+ boost::type_traits::ice_and<
2253
+ boost::is_arithmetic<Source>::value,
2254
+ boost::is_arithmetic<Target>::value,
2255
+ boost::type_traits::ice_not<
1985
2256
  detail::is_char_or_wchar<Target>::value
1986
2257
  >::value,
1987
- ::boost::type_traits::ice_not<
2258
+ boost::type_traits::ice_not<
1988
2259
  detail::is_char_or_wchar<Source>::value
1989
2260
  >::value
1990
2261
  >::value
@@ -2002,14 +2273,14 @@ namespace boost {
2002
2273
  {
2003
2274
  BOOST_STATIC_CONSTANT(bool, value =
2004
2275
  (
2005
- ::boost::type_traits::ice_or<
2006
- ::boost::type_traits::ice_and<
2276
+ boost::type_traits::ice_or<
2277
+ boost::type_traits::ice_and<
2007
2278
  is_same<Source,Target>::value,
2008
2279
  is_char_or_wchar<Target>::value
2009
2280
  >::value,
2010
- ::boost::type_traits::ice_and<
2011
- ::boost::type_traits::ice_eq< sizeof(char),sizeof(Target)>::value,
2012
- ::boost::type_traits::ice_eq< sizeof(char),sizeof(Source)>::value,
2281
+ boost::type_traits::ice_and<
2282
+ boost::type_traits::ice_eq< sizeof(char),sizeof(Target)>::value,
2283
+ boost::type_traits::ice_eq< sizeof(char),sizeof(Source)>::value,
2013
2284
  is_char_or_wchar<Target>::value,
2014
2285
  is_char_or_wchar<Source>::value
2015
2286
  >::value
@@ -2018,28 +2289,6 @@ namespace boost {
2018
2289
  );
2019
2290
  };
2020
2291
 
2021
-
2022
- // this metafunction evaluates to true, if we have optimized comnversion
2023
- // from Float type to Char array.
2024
- // Must be in sync with lexical_stream_limited_src<Char, ...>::shl_real_type(...)
2025
- template <typename Float, typename Char>
2026
- struct is_this_float_conversion_optimized
2027
- {
2028
- typedef ::boost::type_traits::ice_and<
2029
- ::boost::is_float<Float>::value,
2030
- #if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_SWPRINTF) && !defined(__MINGW32__)
2031
- ::boost::type_traits::ice_or<
2032
- ::boost::type_traits::ice_eq<sizeof(Char), sizeof(char) >::value,
2033
- ::boost::is_same<Char, wchar_t>::value
2034
- >::value
2035
- #else
2036
- ::boost::type_traits::ice_eq<sizeof(Char), sizeof(char) >::value
2037
- #endif
2038
- > result_type;
2039
-
2040
- BOOST_STATIC_CONSTANT(bool, value = (result_type::value) );
2041
- };
2042
-
2043
2292
  template<typename Target, typename Source>
2044
2293
  struct is_char_array_to_stdstring
2045
2294
  {
@@ -2059,13 +2308,13 @@ namespace boost {
2059
2308
  };
2060
2309
 
2061
2310
  template<typename CharT, typename Traits, typename Alloc>
2062
- struct is_char_array_to_stdstring< ::boost::container::basic_string<CharT, Traits, Alloc>, CharT* >
2311
+ struct is_char_array_to_stdstring< boost::container::basic_string<CharT, Traits, Alloc>, CharT* >
2063
2312
  {
2064
2313
  BOOST_STATIC_CONSTANT(bool, value = true );
2065
2314
  };
2066
2315
 
2067
2316
  template<typename CharT, typename Traits, typename Alloc>
2068
- struct is_char_array_to_stdstring< ::boost::container::basic_string<CharT, Traits, Alloc>, const CharT* >
2317
+ struct is_char_array_to_stdstring< boost::container::basic_string<CharT, Traits, Alloc>, const CharT* >
2069
2318
  {
2070
2319
  BOOST_STATIC_CONSTANT(bool, value = true );
2071
2320
  };
@@ -2081,60 +2330,21 @@ namespace boost {
2081
2330
  {
2082
2331
  static inline Target lexical_cast_impl(const Source& arg)
2083
2332
  {
2084
- typedef BOOST_DEDUCED_TYPENAME detail::array_to_pointer_decay<Source>::type src;
2085
- typedef BOOST_DEDUCED_TYPENAME ::boost::remove_cv<src>::type no_cv_src;
2086
- typedef BOOST_DEDUCED_TYPENAME detail::stream_char<Target>::type target_char_t;
2087
- typedef BOOST_DEDUCED_TYPENAME detail::stream_char<no_cv_src>::type src_char_type;
2088
- typedef BOOST_DEDUCED_TYPENAME detail::widest_char<
2089
- target_char_t, src_char_type
2090
- >::type char_type;
2091
-
2092
- #if !defined(BOOST_NO_CHAR16_T) && defined(BOOST_NO_UNICODE_LITERALS)
2093
- BOOST_STATIC_ASSERT_MSG(( !::boost::is_same<char16_t, src_char_type>::value
2094
- && !::boost::is_same<char16_t, target_char_t>::value),
2095
- "Your compiler does not have full support for char16_t" );
2096
- #endif
2097
- #if !defined(BOOST_NO_CHAR32_T) && defined(BOOST_NO_UNICODE_LITERALS)
2098
- BOOST_STATIC_ASSERT_MSG(( !::boost::is_same<char32_t, src_char_type>::value
2099
- && !::boost::is_same<char32_t, target_char_t>::value),
2100
- "Your compiler does not have full support for char32_t" );
2101
- #endif
2102
-
2103
- typedef BOOST_DEDUCED_TYPENAME ::boost::detail::deduce_char_traits<
2104
- char_type, Target, no_cv_src
2105
- >::type traits;
2106
-
2107
- typedef ::boost::type_traits::ice_and<
2108
- ::boost::detail::is_char_or_wchar<src_char_type>::value, // source is lexical type
2109
- ::boost::detail::is_char_or_wchar<target_char_t>::value, // target is a lexical type
2110
- ::boost::is_same<char, src_char_type>::value, // source is not a wide character based type
2111
- ::boost::type_traits::ice_ne<sizeof(char), sizeof(target_char_t) >::value // target type is based on wide character
2112
- > is_string_widening_required_t;
2113
-
2114
- typedef ::boost::type_traits::ice_or<
2115
- ::boost::is_integral<no_cv_src>::value,
2116
- ::boost::detail::is_this_float_conversion_optimized<no_cv_src, char_type >::value,
2117
- ::boost::detail::is_char_or_wchar<src_char_type >::value
2118
- > is_source_input_optimized_t;
2333
+ typedef lexical_cast_stream_traits<Source, Target> stream_trait;
2334
+
2335
+ typedef detail::lexical_stream_limited_src<
2336
+ BOOST_DEDUCED_TYPENAME stream_trait::char_type,
2337
+ BOOST_DEDUCED_TYPENAME stream_trait::traits,
2338
+ stream_trait::requires_stringbuf
2339
+ > interpreter_type;
2119
2340
 
2120
2341
  // Target type must be default constructible
2121
- Target result;
2122
-
2123
- // If we have an optimized conversion for
2124
- // Source, we do not need to construct stringbuf.
2125
- const bool requires_stringbuf = ::boost::type_traits::ice_or<
2126
- is_string_widening_required_t::value,
2127
- ::boost::type_traits::ice_not< is_source_input_optimized_t::value >::value
2128
- >::value;
2129
-
2130
- typedef detail::lexical_stream_limited_src<char_type, traits, requires_stringbuf > interpreter_type;
2342
+ Target result;
2131
2343
 
2132
- typedef detail::lcast_src_length<no_cv_src> lcast_src_length;
2133
- std::size_t const src_len = lcast_src_length::value;
2134
- char_type buf[src_len + 1];
2135
- lcast_src_length::check_coverage();
2344
+ BOOST_DEDUCED_TYPENAME stream_trait::char_type buf[stream_trait::len_t::value + 1];
2345
+ stream_trait::len_t::check_coverage();
2136
2346
 
2137
- interpreter_type interpreter(buf, buf + src_len);
2347
+ interpreter_type interpreter(buf, buf + stream_trait::len_t::value + 1);
2138
2348
 
2139
2349
  // Disabling ADL, by directly specifying operators.
2140
2350
  if(!(interpreter.operator <<(arg) && interpreter.operator >>(result)))
@@ -2163,16 +2373,19 @@ namespace boost {
2163
2373
  typedef Source source_type ;
2164
2374
 
2165
2375
  typedef BOOST_DEDUCED_TYPENAME mpl::if_<
2166
- ::boost::is_arithmetic<Source>, Source, Source const&
2376
+ boost::is_arithmetic<Source>, Source, Source const&
2167
2377
  >::type argument_type ;
2168
2378
 
2169
2379
  static source_type nearbyint ( argument_type s )
2170
2380
  {
2171
- const source_type orig_div_round = s / Rounder::nearbyint(s);
2172
- const source_type eps = std::numeric_limits<source_type>::epsilon();
2381
+ const source_type near_int = Rounder::nearbyint(s);
2382
+ if (near_int) {
2383
+ const source_type orig_div_round = s / near_int;
2384
+ const source_type eps = std::numeric_limits<source_type>::epsilon();
2173
2385
 
2174
- if ((orig_div_round > 1 ? orig_div_round - 1 : 1 - orig_div_round) > eps)
2175
- BOOST_LCAST_THROW_BAD_CAST(Source, Target);
2386
+ if ((orig_div_round > 1 ? orig_div_round - 1 : 1 - orig_div_round) > eps)
2387
+ BOOST_LCAST_THROW_BAD_CAST(Source, Target);
2388
+ }
2176
2389
 
2177
2390
  return s ;
2178
2391
  }
@@ -2210,16 +2423,22 @@ namespace boost {
2210
2423
  {
2211
2424
  static inline Target lexical_cast_impl(const Source &arg)
2212
2425
  {
2426
+ typedef BOOST_DEDUCED_TYPENAME boost::mpl::eval_if_c<
2427
+ boost::is_float<Source>::value,
2428
+ boost::mpl::identity<Source>,
2429
+ boost::make_unsigned<Source>
2430
+ >::type usource_t;
2431
+
2213
2432
  typedef boost::numeric::converter<
2214
2433
  Target,
2215
- Source,
2216
- boost::numeric::conversion_traits<Target,Source>,
2217
- nothrow_overflow_handler<Source, Target>,
2218
- detect_precision_loss<Source, Target>
2434
+ usource_t,
2435
+ boost::numeric::conversion_traits<Target,usource_t>,
2436
+ nothrow_overflow_handler<usource_t, Target>,
2437
+ detect_precision_loss<usource_t, Target>
2219
2438
  > converter_t;
2220
2439
 
2221
2440
  return (
2222
- arg < 0 ? -converter_t::convert(-arg) : converter_t::convert(arg)
2441
+ arg < 0 ? static_cast<Target>(0u - converter_t::convert(0u - arg)) : converter_t::convert(arg)
2223
2442
  );
2224
2443
  }
2225
2444
  };
@@ -2247,19 +2466,19 @@ namespace boost {
2247
2466
  {
2248
2467
  static inline Target lexical_cast_impl(const Source &arg)
2249
2468
  {
2250
- typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c<
2251
- ::boost::type_traits::ice_and<
2252
- ::boost::type_traits::ice_or<
2253
- ::boost::is_signed<Source>::value,
2254
- ::boost::is_float<Source>::value
2469
+ typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c<
2470
+ boost::type_traits::ice_and<
2471
+ boost::type_traits::ice_or<
2472
+ boost::is_signed<Source>::value,
2473
+ boost::is_float<Source>::value
2255
2474
  >::value,
2256
- ::boost::type_traits::ice_not<
2257
- ::boost::is_same<Source, bool>::value
2475
+ boost::type_traits::ice_not<
2476
+ boost::is_same<Source, bool>::value
2258
2477
  >::value,
2259
- ::boost::type_traits::ice_not<
2260
- ::boost::is_same<Target, bool>::value
2478
+ boost::type_traits::ice_not<
2479
+ boost::is_same<Target, bool>::value
2261
2480
  >::value,
2262
- ::boost::is_unsigned<Target>::value
2481
+ boost::is_unsigned<Target>::value
2263
2482
  >::value,
2264
2483
  lexical_cast_dynamic_num_ignoring_minus<Target, Source>,
2265
2484
  lexical_cast_dynamic_num_not_ignoring_minus<Target, Source>
@@ -2273,27 +2492,27 @@ namespace boost {
2273
2492
  template <typename Target, typename Source>
2274
2493
  inline Target lexical_cast(const Source &arg)
2275
2494
  {
2276
- typedef BOOST_DEDUCED_TYPENAME ::boost::detail::array_to_pointer_decay<Source>::type src;
2277
-
2278
- typedef BOOST_DEDUCED_TYPENAME ::boost::type_traits::ice_or<
2279
- ::boost::detail::is_xchar_to_xchar<Target, src >::value,
2280
- ::boost::detail::is_char_array_to_stdstring<Target, src >::value,
2281
- ::boost::type_traits::ice_and<
2282
- ::boost::is_same<Target, src >::value,
2283
- ::boost::detail::is_stdstring<Target >::value
2495
+ typedef BOOST_DEDUCED_TYPENAME boost::detail::array_to_pointer_decay<Source>::type src;
2496
+
2497
+ typedef BOOST_DEDUCED_TYPENAME boost::type_traits::ice_or<
2498
+ boost::detail::is_xchar_to_xchar<Target, src >::value,
2499
+ boost::detail::is_char_array_to_stdstring<Target, src >::value,
2500
+ boost::type_traits::ice_and<
2501
+ boost::is_same<Target, src >::value,
2502
+ boost::detail::is_stdstring<Target >::value
2284
2503
  >::value
2285
2504
  > shall_we_copy_t;
2286
2505
 
2287
2506
  typedef BOOST_DEDUCED_TYPENAME
2288
- ::boost::detail::is_arithmetic_and_not_xchars<Target, src > shall_we_copy_with_dynamic_check_t;
2507
+ boost::detail::is_arithmetic_and_not_xchars<Target, src > shall_we_copy_with_dynamic_check_t;
2289
2508
 
2290
- typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c<
2509
+ typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c<
2291
2510
  shall_we_copy_t::value,
2292
- ::boost::detail::lexical_cast_copy<src >,
2293
- BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c<
2511
+ boost::detail::lexical_cast_copy<src >,
2512
+ BOOST_DEDUCED_TYPENAME boost::mpl::if_c<
2294
2513
  shall_we_copy_with_dynamic_check_t::value,
2295
- ::boost::detail::lexical_cast_dynamic_num<Target, src >,
2296
- ::boost::detail::lexical_cast_do_cast<Target, src >
2514
+ boost::detail::lexical_cast_dynamic_num<Target, src >,
2515
+ boost::detail::lexical_cast_do_cast<Target, src >
2297
2516
  >::type
2298
2517
  >::type caster_type;
2299
2518
 
@@ -2302,7 +2521,7 @@ namespace boost {
2302
2521
 
2303
2522
  template <typename Target>
2304
2523
  inline Target lexical_cast(const char* chars, std::size_t count)
2305
- {
2524
+ {
2306
2525
  return ::boost::lexical_cast<Target>(
2307
2526
  ::boost::iterator_range<const char*>(chars, chars + count)
2308
2527
  );
@@ -2312,10 +2531,10 @@ namespace boost {
2312
2531
  template <typename Target>
2313
2532
  inline Target lexical_cast(const unsigned char* chars, std::size_t count)
2314
2533
  {
2315
- return ::boost::lexical_cast<Target>(
2534
+ return ::boost::lexical_cast<Target>(
2316
2535
  ::boost::iterator_range<const unsigned char*>(chars, chars + count)
2317
- );
2318
- }
2536
+ );
2537
+ }
2319
2538
 
2320
2539
  template <typename Target>
2321
2540
  inline Target lexical_cast(const signed char* chars, std::size_t count)
@@ -2492,7 +2711,7 @@ namespace boost {
2492
2711
 
2493
2712
  // Copyright Kevlin Henney, 2000-2005.
2494
2713
  // Copyright Alexander Nasonov, 2006-2010.
2495
- // Copyright Antony Polukhin, 2011-2012.
2714
+ // Copyright Antony Polukhin, 2011-2013.
2496
2715
  //
2497
2716
  // Distributed under the Boost Software License, Version 1.0. (See
2498
2717
  // accompanying file LICENSE_1_0.txt or copy at
@@ -2500,6 +2719,7 @@ namespace boost {
2500
2719
 
2501
2720
  #undef BOOST_LCAST_THROW_BAD_CAST
2502
2721
  #undef BOOST_LCAST_NO_WCHAR_T
2722
+ #undef BOOST_LCAST_HAS_INT128
2503
2723
 
2504
2724
  #endif // BOOST_LEXICAL_CAST_INCLUDED
2505
2725