couchbase 3.5.1 → 3.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1166) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/ext/0001-fix-build-for-mingw-w64-ucrt-x86_64-toolchain.patch +40 -0
  4. data/ext/CMakeLists.txt +22 -2
  5. data/ext/cache/extconf_include.rb +3 -3
  6. data/ext/cache/mozilla-ca-bundle.crt +19 -32
  7. data/ext/cache/mozilla-ca-bundle.sha256 +1 -1
  8. data/ext/couchbase/CMakeLists.txt +16 -9
  9. data/ext/couchbase/cmake/0001-fix-build-for-mingw-w64-ucrt-x86_64-toolchain.patch +3 -4
  10. data/ext/couchbase/cmake/CompilerWarnings.cmake +2 -1
  11. data/ext/couchbase/cmake/Packaging.cmake +41 -0
  12. data/ext/couchbase/cmake/Sanitizers.cmake +1 -0
  13. data/ext/couchbase/cmake/VersionInfo.cmake +5 -5
  14. data/ext/couchbase/cmake/build_version.hxx.in +1 -0
  15. data/ext/couchbase/cmake/couchbase-cxx-client.pc.in +10 -0
  16. data/ext/couchbase/cmake/test_boringssl.cxx +1 -1
  17. data/ext/couchbase/cmake/test_openssl.cxx +1 -1
  18. data/ext/couchbase/core/agent.cxx +353 -304
  19. data/ext/couchbase/core/agent.hxx +94 -76
  20. data/ext/couchbase/core/agent_config.cxx +9 -8
  21. data/ext/couchbase/core/agent_config.hxx +7 -7
  22. data/ext/couchbase/core/agent_group.cxx +132 -120
  23. data/ext/couchbase/core/agent_group.hxx +26 -22
  24. data/ext/couchbase/core/agent_group_config.cxx +8 -7
  25. data/ext/couchbase/core/agent_group_config.hxx +6 -6
  26. data/ext/couchbase/core/agent_unit_test_api.hxx +6 -6
  27. data/ext/couchbase/core/analytics_query_options.cxx +21 -21
  28. data/ext/couchbase/core/analytics_query_options.hxx +19 -18
  29. data/ext/couchbase/core/analytics_scan_consistency.hxx +2 -2
  30. data/ext/couchbase/core/bucket.cxx +848 -776
  31. data/ext/couchbase/core/bucket.hxx +151 -139
  32. data/ext/couchbase/core/capella_ca.hxx +20 -19
  33. data/ext/couchbase/core/cluster.cxx +1240 -927
  34. data/ext/couchbase/core/cluster.hxx +254 -167
  35. data/ext/couchbase/core/cluster_agent.cxx +7 -7
  36. data/ext/couchbase/core/cluster_agent.hxx +4 -4
  37. data/ext/couchbase/core/cluster_agent_config.cxx +8 -7
  38. data/ext/couchbase/core/cluster_agent_config.hxx +6 -6
  39. data/ext/couchbase/core/cluster_options.cxx +17 -17
  40. data/ext/couchbase/core/cluster_options.hxx +50 -47
  41. data/ext/couchbase/core/cluster_state.hxx +3 -3
  42. data/ext/couchbase/core/collection_id_cache_entry.hxx +5 -4
  43. data/ext/couchbase/core/collections_component.cxx +372 -329
  44. data/ext/couchbase/core/collections_component.hxx +17 -13
  45. data/ext/couchbase/core/collections_component_unit_test_api.hxx +6 -6
  46. data/ext/couchbase/core/collections_options.hxx +29 -27
  47. data/ext/couchbase/core/config_listener.hxx +3 -3
  48. data/ext/couchbase/core/config_profile.hxx +3 -3
  49. data/ext/couchbase/core/config_profiles.cxx +31 -31
  50. data/ext/couchbase/core/config_profiles.hxx +19 -19
  51. data/ext/couchbase/core/core_sdk_shim.cxx +2 -1
  52. data/ext/couchbase/core/core_sdk_shim.hxx +2 -2
  53. data/ext/couchbase/core/crud_component.cxx +310 -276
  54. data/ext/couchbase/core/crud_component.hxx +21 -15
  55. data/ext/couchbase/core/crud_options.hxx +361 -354
  56. data/ext/couchbase/core/crypto/cbcrypto.cc +732 -627
  57. data/ext/couchbase/core/crypto/cbcrypto.h +12 -3
  58. data/ext/couchbase/core/design_document_namespace.hxx +2 -2
  59. data/ext/couchbase/core/design_document_namespace_fmt.hxx +18 -18
  60. data/ext/couchbase/core/diagnostics.hxx +44 -44
  61. data/ext/couchbase/core/diagnostics_fmt.hxx +76 -76
  62. data/ext/couchbase/core/diagnostics_json.hxx +61 -60
  63. data/ext/couchbase/core/diagntostics_options.hxx +14 -14
  64. data/ext/couchbase/core/dispatcher.cxx +4 -3
  65. data/ext/couchbase/core/dispatcher.hxx +8 -7
  66. data/ext/couchbase/core/document_id.cxx +37 -34
  67. data/ext/couchbase/core/document_id.hxx +87 -86
  68. data/ext/couchbase/core/document_id_fmt.hxx +10 -10
  69. data/ext/couchbase/core/durability_options.hxx +50 -49
  70. data/ext/couchbase/core/error_context/analytics.hxx +18 -18
  71. data/ext/couchbase/core/error_context/analytics_json.hxx +115 -0
  72. data/ext/couchbase/core/error_context/base_error_context.hxx +184 -0
  73. data/ext/couchbase/core/error_context/http.hxx +14 -14
  74. data/ext/couchbase/core/error_context/http_json.hxx +90 -0
  75. data/ext/couchbase/core/error_context/internal_tof_metadata_json.hxx +36 -0
  76. data/ext/couchbase/core/error_context/key_value.cxx +27 -27
  77. data/ext/couchbase/core/error_context/key_value.hxx +41 -38
  78. data/ext/couchbase/core/error_context/key_value_error_context.hxx +235 -0
  79. data/ext/couchbase/core/error_context/key_value_error_map_attribute.hxx +142 -0
  80. data/ext/couchbase/core/error_context/key_value_error_map_info.hxx +139 -0
  81. data/ext/couchbase/core/error_context/key_value_extended_error_info.hxx +86 -0
  82. data/ext/couchbase/core/error_context/key_value_json.hxx +83 -0
  83. data/ext/couchbase/core/error_context/key_value_status_code.hxx +109 -0
  84. data/ext/couchbase/core/error_context/query.hxx +18 -18
  85. data/ext/couchbase/core/error_context/query_error_context.hxx +150 -0
  86. data/ext/couchbase/core/error_context/query_json.hxx +114 -0
  87. data/ext/couchbase/core/error_context/query_public_json.hxx +84 -0
  88. data/ext/couchbase/core/error_context/search.hxx +17 -17
  89. data/ext/couchbase/core/error_context/search_json.hxx +101 -0
  90. data/ext/couchbase/core/error_context/subdocument_error_context.hxx +147 -0
  91. data/ext/couchbase/core/error_context/subdocument_json.hxx +48 -0
  92. data/ext/couchbase/{couchbase → core/error_context}/transaction_error_context.hxx +22 -22
  93. data/ext/couchbase/core/error_context/transaction_op_error_context.hxx +79 -0
  94. data/ext/couchbase/core/error_context/view.hxx +17 -17
  95. data/ext/couchbase/core/fmt/key_value_error_map_attribute.hxx +100 -0
  96. data/ext/couchbase/{couchbase → core}/fmt/key_value_extended_error_info.hxx +20 -20
  97. data/ext/couchbase/core/fmt/key_value_status_code.hxx +269 -0
  98. data/ext/couchbase/core/free_form_http_request.cxx +26 -26
  99. data/ext/couchbase/core/free_form_http_request.hxx +34 -33
  100. data/ext/couchbase/core/impl/analytics.cxx +111 -131
  101. data/ext/couchbase/core/impl/analytics.hxx +5 -7
  102. data/ext/couchbase/core/impl/analytics_error_category.cxx +29 -28
  103. data/ext/couchbase/core/impl/analytics_index_manager.cxx +615 -516
  104. data/ext/couchbase/core/impl/best_effort_retry_strategy.cxx +53 -50
  105. data/ext/couchbase/core/impl/binary_collection.cxx +346 -285
  106. data/ext/couchbase/core/impl/boolean_field_query.cxx +10 -10
  107. data/ext/couchbase/core/impl/boolean_query.cxx +27 -27
  108. data/ext/couchbase/core/impl/bootstrap_state_listener.hxx +6 -6
  109. data/ext/couchbase/core/impl/bucket.cxx +39 -34
  110. data/ext/couchbase/core/impl/bucket_manager.cxx +354 -313
  111. data/ext/couchbase/core/impl/cluster.cxx +430 -325
  112. data/ext/couchbase/core/impl/collection.cxx +1033 -1187
  113. data/ext/couchbase/core/impl/collection_manager.cxx +201 -170
  114. data/ext/couchbase/core/impl/common_error_category.cxx +58 -55
  115. data/ext/couchbase/core/impl/configuration_profiles_registry.cxx +46 -32
  116. data/ext/couchbase/core/impl/conjunction_query.cxx +17 -17
  117. data/ext/couchbase/core/impl/date_range.cxx +24 -20
  118. data/ext/couchbase/core/impl/date_range_facet.cxx +22 -22
  119. data/ext/couchbase/core/impl/date_range_facet_result.cxx +6 -6
  120. data/ext/couchbase/core/impl/date_range_query.cxx +50 -48
  121. data/ext/couchbase/core/impl/diagnostics.cxx +211 -198
  122. data/ext/couchbase/core/impl/diagnostics.hxx +7 -6
  123. data/ext/couchbase/core/impl/disjunction_query.cxx +18 -17
  124. data/ext/couchbase/core/impl/dns_srv_tracker.cxx +92 -75
  125. data/ext/couchbase/core/impl/dns_srv_tracker.hxx +24 -20
  126. data/ext/couchbase/core/impl/doc_id_query.cxx +9 -9
  127. data/ext/couchbase/core/impl/encoded_search_facet.hxx +2 -2
  128. data/ext/couchbase/core/impl/encoded_search_query.hxx +2 -2
  129. data/ext/couchbase/core/impl/encoded_search_sort.hxx +2 -2
  130. data/ext/couchbase/core/impl/error.cxx +171 -0
  131. data/ext/couchbase/core/impl/error.hxx +64 -0
  132. data/ext/couchbase/core/impl/error_context.cxx +56 -0
  133. data/ext/couchbase/core/impl/expiry.cxx +66 -53
  134. data/ext/couchbase/core/impl/fail_fast_retry_strategy.cxx +5 -4
  135. data/ext/couchbase/core/impl/field_level_encryption_error_category.cxx +30 -28
  136. data/ext/couchbase/core/impl/geo_bounding_box_query.cxx +17 -17
  137. data/ext/couchbase/core/impl/geo_distance_query.cxx +14 -14
  138. data/ext/couchbase/core/impl/geo_polygon_query.cxx +17 -17
  139. data/ext/couchbase/core/impl/get_all_replicas.hxx +26 -22
  140. data/ext/couchbase/core/impl/get_any_replica.hxx +25 -23
  141. data/ext/couchbase/core/impl/get_replica.cxx +18 -15
  142. data/ext/couchbase/core/impl/get_replica.hxx +23 -18
  143. data/ext/couchbase/core/impl/internal_date_range_facet_result.cxx +16 -14
  144. data/ext/couchbase/core/impl/internal_date_range_facet_result.hxx +16 -15
  145. data/ext/couchbase/core/impl/internal_error_context.cxx +79 -0
  146. data/ext/couchbase/core/impl/internal_error_context.hxx +52 -0
  147. data/ext/couchbase/core/impl/internal_numeric_range_facet_result.cxx +18 -15
  148. data/ext/couchbase/core/impl/internal_numeric_range_facet_result.hxx +16 -15
  149. data/ext/couchbase/core/impl/internal_scan_result.hxx +7 -7
  150. data/ext/couchbase/core/impl/internal_search_error_context.cxx +25 -22
  151. data/ext/couchbase/core/impl/internal_search_error_context.hxx +32 -31
  152. data/ext/couchbase/core/impl/internal_search_meta_data.cxx +15 -13
  153. data/ext/couchbase/core/impl/internal_search_meta_data.hxx +10 -9
  154. data/ext/couchbase/core/impl/internal_search_result.cxx +30 -22
  155. data/ext/couchbase/core/impl/internal_search_result.hxx +10 -9
  156. data/ext/couchbase/core/impl/internal_search_row.cxx +10 -10
  157. data/ext/couchbase/core/impl/internal_search_row.hxx +16 -16
  158. data/ext/couchbase/core/impl/internal_search_row_location.hxx +2 -2
  159. data/ext/couchbase/core/impl/internal_search_row_locations.cxx +68 -65
  160. data/ext/couchbase/core/impl/internal_search_row_locations.hxx +16 -13
  161. data/ext/couchbase/core/impl/internal_term_facet_result.cxx +16 -14
  162. data/ext/couchbase/core/impl/internal_term_facet_result.hxx +15 -15
  163. data/ext/couchbase/core/impl/key_value_error_category.cxx +73 -72
  164. data/ext/couchbase/core/impl/key_value_error_context.cxx +65 -65
  165. data/ext/couchbase/core/impl/logger.cxx +91 -0
  166. data/ext/couchbase/core/impl/lookup_in_all_replicas.hxx +32 -29
  167. data/ext/couchbase/core/impl/lookup_in_any_replica.hxx +33 -29
  168. data/ext/couchbase/core/impl/lookup_in_replica.cxx +75 -68
  169. data/ext/couchbase/core/impl/lookup_in_replica.hxx +30 -26
  170. data/ext/couchbase/core/impl/management_error_category.cxx +41 -40
  171. data/ext/couchbase/core/impl/match_all_query.cxx +6 -6
  172. data/ext/couchbase/core/impl/match_none_query.cxx +6 -6
  173. data/ext/couchbase/core/impl/match_phrase_query.cxx +13 -13
  174. data/ext/couchbase/core/impl/match_query.cxx +28 -28
  175. data/ext/couchbase/core/impl/network_error_category.cxx +39 -38
  176. data/ext/couchbase/core/impl/numeric_range.cxx +6 -6
  177. data/ext/couchbase/core/impl/numeric_range_facet.cxx +22 -22
  178. data/ext/couchbase/core/impl/numeric_range_facet_result.cxx +6 -6
  179. data/ext/couchbase/core/impl/numeric_range_query.cxx +22 -22
  180. data/ext/couchbase/core/impl/observe_poll.cxx +294 -277
  181. data/ext/couchbase/core/impl/observe_poll.hxx +1 -1
  182. data/ext/couchbase/core/impl/observe_seqno.cxx +21 -18
  183. data/ext/couchbase/core/impl/observe_seqno.hxx +31 -26
  184. data/ext/couchbase/core/impl/phrase_query.cxx +10 -10
  185. data/ext/couchbase/core/impl/prefix_query.cxx +10 -10
  186. data/ext/couchbase/core/impl/query.cxx +163 -154
  187. data/ext/couchbase/core/impl/query.hxx +6 -7
  188. data/ext/couchbase/core/impl/query_error_category.cxx +22 -21
  189. data/ext/couchbase/core/impl/query_error_context.cxx +45 -45
  190. data/ext/couchbase/core/impl/query_index_manager.cxx +488 -408
  191. data/ext/couchbase/core/impl/query_string_query.cxx +7 -7
  192. data/ext/couchbase/core/impl/regexp_query.cxx +10 -10
  193. data/ext/couchbase/core/impl/replica_utils.cxx +66 -0
  194. data/ext/couchbase/core/impl/replica_utils.hxx +48 -0
  195. data/ext/couchbase/core/impl/retry_action.cxx +3 -3
  196. data/ext/couchbase/core/impl/retry_reason.cxx +129 -56
  197. data/ext/couchbase/core/impl/retry_reason.hxx +28 -0
  198. data/ext/couchbase/core/impl/scan_result.cxx +53 -49
  199. data/ext/couchbase/core/impl/scope.cxx +103 -94
  200. data/ext/couchbase/core/impl/search.cxx +139 -130
  201. data/ext/couchbase/core/impl/search.hxx +4 -4
  202. data/ext/couchbase/core/impl/search_error_category.cxx +18 -17
  203. data/ext/couchbase/core/impl/search_index_manager.cxx +492 -390
  204. data/ext/couchbase/core/impl/search_meta_data.cxx +3 -3
  205. data/ext/couchbase/core/impl/search_request.cxx +78 -78
  206. data/ext/couchbase/core/impl/search_result.cxx +5 -5
  207. data/ext/couchbase/core/impl/search_row.cxx +7 -7
  208. data/ext/couchbase/core/impl/search_row_location.cxx +9 -8
  209. data/ext/couchbase/core/impl/search_row_locations.cxx +8 -7
  210. data/ext/couchbase/core/impl/search_sort_field.cxx +53 -53
  211. data/ext/couchbase/core/impl/search_sort_geo_distance.cxx +49 -48
  212. data/ext/couchbase/core/impl/search_sort_id.cxx +10 -10
  213. data/ext/couchbase/core/impl/search_sort_score.cxx +10 -10
  214. data/ext/couchbase/core/impl/streaming_json_lexer_error_category.cxx +70 -68
  215. data/ext/couchbase/core/impl/subdoc/array_add_unique.cxx +6 -6
  216. data/ext/couchbase/core/impl/subdoc/array_append.cxx +6 -6
  217. data/ext/couchbase/core/impl/subdoc/array_insert.cxx +6 -6
  218. data/ext/couchbase/core/impl/subdoc/array_prepend.cxx +6 -6
  219. data/ext/couchbase/core/impl/subdoc/command.hxx +5 -5
  220. data/ext/couchbase/core/impl/subdoc/command_bundle.hxx +11 -11
  221. data/ext/couchbase/core/impl/subdoc/count.cxx +6 -6
  222. data/ext/couchbase/core/impl/subdoc/counter.cxx +6 -6
  223. data/ext/couchbase/core/impl/subdoc/exists.cxx +6 -6
  224. data/ext/couchbase/core/impl/subdoc/get.cxx +6 -6
  225. data/ext/couchbase/core/impl/subdoc/insert.cxx +6 -6
  226. data/ext/couchbase/core/impl/subdoc/join_values.cxx +25 -25
  227. data/ext/couchbase/core/impl/subdoc/lookup_in_macro.cxx +61 -60
  228. data/ext/couchbase/core/impl/subdoc/lookup_in_specs.cxx +9 -9
  229. data/ext/couchbase/core/impl/subdoc/mutate_in_macro.cxx +48 -39
  230. data/ext/couchbase/core/impl/subdoc/mutate_in_specs.cxx +9 -9
  231. data/ext/couchbase/core/impl/subdoc/opcode.hxx +16 -16
  232. data/ext/couchbase/core/impl/subdoc/path_flags.hxx +40 -17
  233. data/ext/couchbase/core/impl/subdoc/remove.cxx +6 -6
  234. data/ext/couchbase/core/impl/subdoc/replace.cxx +6 -6
  235. data/ext/couchbase/core/impl/subdoc/upsert.cxx +6 -6
  236. data/ext/couchbase/core/impl/term_facet.cxx +8 -8
  237. data/ext/couchbase/core/impl/term_facet_result.cxx +6 -6
  238. data/ext/couchbase/core/impl/term_query.cxx +25 -25
  239. data/ext/couchbase/core/impl/term_range_query.cxx +22 -22
  240. data/ext/couchbase/core/impl/transaction_error_category.cxx +21 -20
  241. data/ext/couchbase/core/impl/transaction_get_result.cxx +41 -30
  242. data/ext/couchbase/core/impl/transaction_op_error_category.cxx +55 -56
  243. data/ext/couchbase/core/impl/vector_query.cxx +15 -10
  244. data/ext/couchbase/core/impl/vector_search.cxx +9 -9
  245. data/ext/couchbase/core/impl/view_error_category.cxx +17 -16
  246. data/ext/couchbase/core/impl/wildcard_query.cxx +10 -10
  247. data/ext/couchbase/core/impl/with_legacy_durability.hxx +30 -29
  248. data/ext/couchbase/core/io/dns_client.cxx +257 -232
  249. data/ext/couchbase/core/io/dns_client.hxx +19 -18
  250. data/ext/couchbase/core/io/dns_codec.hxx +156 -154
  251. data/ext/couchbase/core/io/dns_config.cxx +114 -109
  252. data/ext/couchbase/core/io/dns_config.hxx +15 -13
  253. data/ext/couchbase/core/io/dns_message.hxx +365 -342
  254. data/ext/couchbase/core/io/http_command.hxx +155 -134
  255. data/ext/couchbase/core/io/http_context.hxx +5 -5
  256. data/ext/couchbase/core/io/http_message.hxx +75 -71
  257. data/ext/couchbase/core/io/http_parser.cxx +70 -67
  258. data/ext/couchbase/core/io/http_parser.hxx +18 -18
  259. data/ext/couchbase/core/io/http_session.hxx +620 -520
  260. data/ext/couchbase/core/io/http_session_manager.hxx +406 -315
  261. data/ext/couchbase/core/io/http_traits.hxx +7 -0
  262. data/ext/couchbase/core/io/ip_protocol.hxx +3 -3
  263. data/ext/couchbase/core/io/mcbp_command.hxx +298 -278
  264. data/ext/couchbase/core/io/mcbp_context.hxx +7 -6
  265. data/ext/couchbase/core/io/mcbp_message.cxx +8 -8
  266. data/ext/couchbase/core/io/mcbp_message.hxx +19 -19
  267. data/ext/couchbase/core/io/mcbp_parser.cxx +60 -51
  268. data/ext/couchbase/core/io/mcbp_parser.hxx +21 -17
  269. data/ext/couchbase/core/io/mcbp_session.cxx +1769 -1616
  270. data/ext/couchbase/core/io/mcbp_session.hxx +63 -57
  271. data/ext/couchbase/core/io/query_cache.hxx +34 -34
  272. data/ext/couchbase/core/io/retry_context.hxx +45 -45
  273. data/ext/couchbase/core/io/retry_orchestrator.hxx +52 -42
  274. data/ext/couchbase/core/io/streams.hxx +210 -193
  275. data/ext/couchbase/core/json_string.hxx +47 -47
  276. data/ext/couchbase/core/key_value_config.cxx +8 -8
  277. data/ext/couchbase/core/key_value_config.hxx +12 -11
  278. data/ext/couchbase/core/logger/configuration.hxx +35 -35
  279. data/ext/couchbase/core/logger/custom_rotating_file_sink.cxx +73 -72
  280. data/ext/couchbase/core/logger/custom_rotating_file_sink.hxx +20 -18
  281. data/ext/couchbase/core/logger/level.hxx +9 -1
  282. data/ext/couchbase/core/logger/logger.cxx +279 -252
  283. data/ext/couchbase/core/logger/logger.hxx +110 -58
  284. data/ext/couchbase/core/management/analytics_dataset.hxx +4 -4
  285. data/ext/couchbase/core/management/analytics_index.hxx +4 -4
  286. data/ext/couchbase/core/management/analytics_link_azure_blob_external.cxx +35 -33
  287. data/ext/couchbase/core/management/analytics_link_azure_blob_external.hxx +36 -35
  288. data/ext/couchbase/core/management/analytics_link_azure_blob_external_json.hxx +24 -20
  289. data/ext/couchbase/core/management/analytics_link_couchbase_remote.cxx +66 -65
  290. data/ext/couchbase/core/management/analytics_link_couchbase_remote.hxx +77 -70
  291. data/ext/couchbase/core/management/analytics_link_couchbase_remote_json.hxx +38 -32
  292. data/ext/couchbase/core/management/analytics_link_s3_external.cxx +26 -25
  293. data/ext/couchbase/core/management/analytics_link_s3_external.hxx +30 -30
  294. data/ext/couchbase/core/management/analytics_link_s3_external_json.hxx +18 -16
  295. data/ext/couchbase/core/management/bucket_settings.hxx +109 -91
  296. data/ext/couchbase/core/management/bucket_settings_json.hxx +112 -94
  297. data/ext/couchbase/core/management/design_document.hxx +9 -9
  298. data/ext/couchbase/core/management/eventing_function.hxx +124 -121
  299. data/ext/couchbase/core/management/eventing_function_json.hxx +228 -184
  300. data/ext/couchbase/core/management/eventing_status.hxx +41 -41
  301. data/ext/couchbase/core/management/eventing_status_json.hxx +53 -45
  302. data/ext/couchbase/core/management/rbac.hxx +33 -28
  303. data/ext/couchbase/core/management/rbac_fmt.hxx +21 -21
  304. data/ext/couchbase/core/management/rbac_json.hxx +132 -125
  305. data/ext/couchbase/core/management/search_index.cxx +79 -0
  306. data/ext/couchbase/core/management/search_index.hxx +11 -10
  307. data/ext/couchbase/core/management/search_index_json.hxx +27 -26
  308. data/ext/couchbase/core/mcbp/barrier_frame.hxx +4 -3
  309. data/ext/couchbase/core/mcbp/big_endian.cxx +22 -22
  310. data/ext/couchbase/core/mcbp/buffer_writer.cxx +22 -19
  311. data/ext/couchbase/core/mcbp/buffer_writer.hxx +9 -9
  312. data/ext/couchbase/core/mcbp/codec.cxx +419 -397
  313. data/ext/couchbase/core/mcbp/codec.hxx +14 -12
  314. data/ext/couchbase/core/mcbp/command_code.cxx +48 -48
  315. data/ext/couchbase/core/mcbp/completion_token.hxx +33 -33
  316. data/ext/couchbase/core/mcbp/datatype.hxx +3 -3
  317. data/ext/couchbase/core/mcbp/durability_level.hxx +8 -7
  318. data/ext/couchbase/core/mcbp/durability_level_frame.hxx +3 -2
  319. data/ext/couchbase/core/mcbp/durability_timeout_frame.hxx +4 -3
  320. data/ext/couchbase/core/mcbp/open_tracing_frame.hxx +3 -2
  321. data/ext/couchbase/core/mcbp/operation_consumer.cxx +3 -3
  322. data/ext/couchbase/core/mcbp/operation_consumer.hxx +9 -9
  323. data/ext/couchbase/core/mcbp/operation_queue.cxx +76 -70
  324. data/ext/couchbase/core/mcbp/operation_queue.hxx +18 -17
  325. data/ext/couchbase/core/mcbp/packet.cxx +65 -51
  326. data/ext/couchbase/core/mcbp/packet.hxx +25 -25
  327. data/ext/couchbase/core/mcbp/preserve_expiry_frame.hxx +4 -2
  328. data/ext/couchbase/core/mcbp/queue_callback.hxx +3 -2
  329. data/ext/couchbase/core/mcbp/queue_request.cxx +65 -62
  330. data/ext/couchbase/core/mcbp/queue_request.hxx +54 -52
  331. data/ext/couchbase/core/mcbp/queue_request_connection_info.hxx +3 -3
  332. data/ext/couchbase/core/mcbp/queue_response.hxx +7 -7
  333. data/ext/couchbase/core/mcbp/read_units_frame.hxx +3 -2
  334. data/ext/couchbase/core/mcbp/server_duration.cxx +7 -7
  335. data/ext/couchbase/core/mcbp/server_duration_frame.hxx +3 -2
  336. data/ext/couchbase/core/mcbp/stream_id_frame.hxx +3 -2
  337. data/ext/couchbase/core/mcbp/unsupported_frame.hxx +4 -3
  338. data/ext/couchbase/core/mcbp/user_impersonation_frame.hxx +1 -1
  339. data/ext/couchbase/core/mcbp/write_units_frame.hxx +3 -2
  340. data/ext/couchbase/core/meta/features.hxx +58 -0
  341. data/ext/couchbase/core/meta/version.cxx +255 -204
  342. data/ext/couchbase/core/meta/version.hxx +31 -20
  343. data/ext/couchbase/core/metrics/logging_meter.cxx +160 -154
  344. data/ext/couchbase/core/metrics/logging_meter.hxx +16 -15
  345. data/ext/couchbase/core/metrics/logging_meter_options.hxx +1 -1
  346. data/ext/couchbase/core/metrics/noop_meter.hxx +14 -13
  347. data/ext/couchbase/core/mozilla_ca_bundle.hxx +2 -2
  348. data/ext/couchbase/core/n1ql_query_options.cxx +31 -31
  349. data/ext/couchbase/core/n1ql_query_options.hxx +22 -21
  350. data/ext/couchbase/core/operation_map.hxx +3 -3
  351. data/ext/couchbase/core/operations/document_analytics.cxx +187 -176
  352. data/ext/couchbase/core/operations/document_analytics.hxx +79 -71
  353. data/ext/couchbase/core/operations/document_append.cxx +18 -15
  354. data/ext/couchbase/core/operations/document_append.hxx +18 -16
  355. data/ext/couchbase/core/operations/document_decrement.cxx +26 -23
  356. data/ext/couchbase/core/operations/document_decrement.hxx +24 -20
  357. data/ext/couchbase/core/operations/document_exists.cxx +23 -21
  358. data/ext/couchbase/core/operations/document_exists.hxx +25 -23
  359. data/ext/couchbase/core/operations/document_get.cxx +17 -15
  360. data/ext/couchbase/core/operations/document_get.hxx +17 -15
  361. data/ext/couchbase/core/operations/document_get_all_replicas.hxx +121 -92
  362. data/ext/couchbase/core/operations/document_get_and_lock.cxx +19 -16
  363. data/ext/couchbase/core/operations/document_get_and_lock.hxx +21 -17
  364. data/ext/couchbase/core/operations/document_get_and_touch.cxx +19 -16
  365. data/ext/couchbase/core/operations/document_get_and_touch.hxx +22 -18
  366. data/ext/couchbase/core/operations/document_get_any_replica.hxx +111 -82
  367. data/ext/couchbase/core/operations/document_get_projected.cxx +193 -184
  368. data/ext/couchbase/core/operations/document_get_projected.hxx +25 -21
  369. data/ext/couchbase/core/operations/document_increment.cxx +26 -23
  370. data/ext/couchbase/core/operations/document_increment.hxx +24 -20
  371. data/ext/couchbase/core/operations/document_insert.cxx +23 -20
  372. data/ext/couchbase/core/operations/document_insert.hxx +20 -18
  373. data/ext/couchbase/core/operations/document_lookup_in.cxx +80 -67
  374. data/ext/couchbase/core/operations/document_lookup_in.hxx +31 -27
  375. data/ext/couchbase/core/operations/document_lookup_in_all_replicas.hxx +187 -149
  376. data/ext/couchbase/core/operations/document_lookup_in_any_replica.hxx +190 -145
  377. data/ext/couchbase/core/operations/document_mutate_in.cxx +98 -80
  378. data/ext/couchbase/core/operations/document_mutate_in.hxx +38 -33
  379. data/ext/couchbase/core/operations/document_prepend.cxx +18 -15
  380. data/ext/couchbase/core/operations/document_prepend.hxx +18 -16
  381. data/ext/couchbase/core/operations/document_query.cxx +367 -356
  382. data/ext/couchbase/core/operations/document_query.hxx +83 -79
  383. data/ext/couchbase/core/operations/document_remove.cxx +18 -15
  384. data/ext/couchbase/core/operations/document_remove.hxx +18 -16
  385. data/ext/couchbase/core/operations/document_replace.cxx +27 -24
  386. data/ext/couchbase/core/operations/document_replace.hxx +22 -20
  387. data/ext/couchbase/core/operations/document_search.cxx +322 -308
  388. data/ext/couchbase/core/operations/document_search.hxx +125 -121
  389. data/ext/couchbase/core/operations/document_touch.cxx +16 -14
  390. data/ext/couchbase/core/operations/document_touch.hxx +19 -17
  391. data/ext/couchbase/core/operations/document_unlock.cxx +16 -14
  392. data/ext/couchbase/core/operations/document_unlock.hxx +19 -17
  393. data/ext/couchbase/core/operations/document_upsert.cxx +26 -23
  394. data/ext/couchbase/core/operations/document_upsert.hxx +21 -19
  395. data/ext/couchbase/core/operations/document_view.cxx +169 -159
  396. data/ext/couchbase/core/operations/document_view.hxx +68 -65
  397. data/ext/couchbase/core/operations/http_noop.cxx +38 -35
  398. data/ext/couchbase/core/operations/http_noop.hxx +12 -10
  399. data/ext/couchbase/core/operations/management/analytics_dataset_create.cxx +58 -56
  400. data/ext/couchbase/core/operations/management/analytics_dataset_create.hxx +20 -17
  401. data/ext/couchbase/core/operations/management/analytics_dataset_drop.cxx +49 -44
  402. data/ext/couchbase/core/operations/management/analytics_dataset_drop.hxx +18 -15
  403. data/ext/couchbase/core/operations/management/analytics_dataset_get_all.cxx +46 -43
  404. data/ext/couchbase/core/operations/management/analytics_dataset_get_all.hxx +16 -13
  405. data/ext/couchbase/core/operations/management/analytics_dataverse_create.cxx +48 -43
  406. data/ext/couchbase/core/operations/management/analytics_dataverse_create.hxx +17 -14
  407. data/ext/couchbase/core/operations/management/analytics_dataverse_drop.cxx +48 -43
  408. data/ext/couchbase/core/operations/management/analytics_dataverse_drop.hxx +17 -14
  409. data/ext/couchbase/core/operations/management/analytics_get_pending_mutations.cxx +38 -35
  410. data/ext/couchbase/core/operations/management/analytics_get_pending_mutations.hxx +16 -14
  411. data/ext/couchbase/core/operations/management/analytics_index_create.cxx +68 -66
  412. data/ext/couchbase/core/operations/management/analytics_index_create.hxx +20 -17
  413. data/ext/couchbase/core/operations/management/analytics_index_drop.cxx +56 -51
  414. data/ext/couchbase/core/operations/management/analytics_index_drop.hxx +19 -16
  415. data/ext/couchbase/core/operations/management/analytics_index_get_all.cxx +44 -42
  416. data/ext/couchbase/core/operations/management/analytics_index_get_all.hxx +16 -13
  417. data/ext/couchbase/core/operations/management/analytics_link_connect.cxx +49 -43
  418. data/ext/couchbase/core/operations/management/analytics_link_connect.hxx +23 -20
  419. data/ext/couchbase/core/operations/management/analytics_link_create.cxx +52 -51
  420. data/ext/couchbase/core/operations/management/analytics_link_create.hxx +33 -30
  421. data/ext/couchbase/core/operations/management/analytics_link_disconnect.cxx +46 -42
  422. data/ext/couchbase/core/operations/management/analytics_link_disconnect.hxx +22 -19
  423. data/ext/couchbase/core/operations/management/analytics_link_drop.cxx +70 -67
  424. data/ext/couchbase/core/operations/management/analytics_link_drop.hxx +22 -19
  425. data/ext/couchbase/core/operations/management/analytics_link_get_all.cxx +92 -85
  426. data/ext/couchbase/core/operations/management/analytics_link_get_all.hxx +27 -24
  427. data/ext/couchbase/core/operations/management/analytics_link_replace.cxx +52 -51
  428. data/ext/couchbase/core/operations/management/analytics_link_replace.hxx +33 -30
  429. data/ext/couchbase/core/operations/management/analytics_link_utils.hxx +6 -4
  430. data/ext/couchbase/core/operations/management/analytics_problem.hxx +2 -2
  431. data/ext/couchbase/core/operations/management/bucket_create.cxx +158 -149
  432. data/ext/couchbase/core/operations/management/bucket_create.hxx +14 -12
  433. data/ext/couchbase/core/operations/management/bucket_describe.cxx +118 -42
  434. data/ext/couchbase/core/operations/management/bucket_describe.hxx +47 -22
  435. data/ext/couchbase/core/operations/management/bucket_drop.cxx +19 -18
  436. data/ext/couchbase/core/operations/management/bucket_drop.hxx +13 -11
  437. data/ext/couchbase/core/operations/management/bucket_flush.cxx +25 -24
  438. data/ext/couchbase/core/operations/management/bucket_flush.hxx +13 -11
  439. data/ext/couchbase/core/operations/management/bucket_get.cxx +24 -22
  440. data/ext/couchbase/core/operations/management/bucket_get.hxx +14 -12
  441. data/ext/couchbase/core/operations/management/bucket_get_all.cxx +25 -23
  442. data/ext/couchbase/core/operations/management/bucket_get_all.hxx +13 -11
  443. data/ext/couchbase/core/operations/management/bucket_update.cxx +112 -107
  444. data/ext/couchbase/core/operations/management/bucket_update.hxx +15 -13
  445. data/ext/couchbase/core/operations/management/change_password.cxx +22 -20
  446. data/ext/couchbase/core/operations/management/change_password.hxx +13 -11
  447. data/ext/couchbase/core/operations/management/cluster_describe.cxx +52 -50
  448. data/ext/couchbase/core/operations/management/cluster_describe.hxx +31 -29
  449. data/ext/couchbase/core/operations/management/cluster_developer_preview_enable.cxx +14 -12
  450. data/ext/couchbase/core/operations/management/cluster_developer_preview_enable.hxx +13 -11
  451. data/ext/couchbase/core/operations/management/collection_create.cxx +48 -46
  452. data/ext/couchbase/core/operations/management/collection_create.hxx +19 -16
  453. data/ext/couchbase/core/operations/management/collection_drop.cxx +37 -35
  454. data/ext/couchbase/core/operations/management/collection_drop.hxx +16 -14
  455. data/ext/couchbase/core/operations/management/collection_update.cxx +49 -47
  456. data/ext/couchbase/core/operations/management/collection_update.hxx +19 -16
  457. data/ext/couchbase/core/operations/management/collections_manifest_get.cxx +11 -9
  458. data/ext/couchbase/core/operations/management/collections_manifest_get.hxx +17 -13
  459. data/ext/couchbase/core/operations/management/error_utils.cxx +210 -198
  460. data/ext/couchbase/core/operations/management/error_utils.hxx +3 -1
  461. data/ext/couchbase/core/operations/management/eventing_deploy_function.cxx +30 -28
  462. data/ext/couchbase/core/operations/management/eventing_deploy_function.hxx +17 -14
  463. data/ext/couchbase/core/operations/management/eventing_drop_function.cxx +31 -29
  464. data/ext/couchbase/core/operations/management/eventing_drop_function.hxx +17 -14
  465. data/ext/couchbase/core/operations/management/eventing_get_all_functions.cxx +49 -43
  466. data/ext/couchbase/core/operations/management/eventing_get_all_functions.hxx +17 -14
  467. data/ext/couchbase/core/operations/management/eventing_get_function.cxx +29 -27
  468. data/ext/couchbase/core/operations/management/eventing_get_function.hxx +18 -15
  469. data/ext/couchbase/core/operations/management/eventing_get_status.cxx +45 -39
  470. data/ext/couchbase/core/operations/management/eventing_get_status.hxx +17 -14
  471. data/ext/couchbase/core/operations/management/eventing_pause_function.cxx +30 -28
  472. data/ext/couchbase/core/operations/management/eventing_pause_function.hxx +17 -14
  473. data/ext/couchbase/core/operations/management/eventing_problem.hxx +3 -3
  474. data/ext/couchbase/core/operations/management/eventing_resume_function.cxx +30 -28
  475. data/ext/couchbase/core/operations/management/eventing_resume_function.hxx +17 -14
  476. data/ext/couchbase/core/operations/management/eventing_undeploy_function.cxx +30 -28
  477. data/ext/couchbase/core/operations/management/eventing_undeploy_function.hxx +17 -14
  478. data/ext/couchbase/core/operations/management/eventing_upsert_function.cxx +328 -318
  479. data/ext/couchbase/core/operations/management/eventing_upsert_function.hxx +17 -14
  480. data/ext/couchbase/core/operations/management/freeform.cxx +23 -22
  481. data/ext/couchbase/core/operations/management/freeform.hxx +19 -17
  482. data/ext/couchbase/core/operations/management/group_drop.cxx +18 -17
  483. data/ext/couchbase/core/operations/management/group_drop.hxx +13 -11
  484. data/ext/couchbase/core/operations/management/group_get.cxx +25 -23
  485. data/ext/couchbase/core/operations/management/group_get.hxx +14 -12
  486. data/ext/couchbase/core/operations/management/group_get_all.cxx +23 -22
  487. data/ext/couchbase/core/operations/management/group_get_all.hxx +13 -11
  488. data/ext/couchbase/core/operations/management/group_upsert.cxx +58 -55
  489. data/ext/couchbase/core/operations/management/group_upsert.hxx +14 -12
  490. data/ext/couchbase/core/operations/management/query_index_build.cxx +53 -48
  491. data/ext/couchbase/core/operations/management/query_index_build.hxx +25 -22
  492. data/ext/couchbase/core/operations/management/query_index_build_deferred.hxx +75 -67
  493. data/ext/couchbase/core/operations/management/query_index_create.cxx +128 -122
  494. data/ext/couchbase/core/operations/management/query_index_create.hxx +31 -28
  495. data/ext/couchbase/core/operations/management/query_index_drop.cxx +95 -93
  496. data/ext/couchbase/core/operations/management/query_index_drop.hxx +26 -24
  497. data/ext/couchbase/core/operations/management/query_index_get_all.cxx +97 -93
  498. data/ext/couchbase/core/operations/management/query_index_get_all.hxx +24 -21
  499. data/ext/couchbase/core/operations/management/query_index_get_all_deferred.cxx +66 -62
  500. data/ext/couchbase/core/operations/management/query_index_get_all_deferred.hxx +24 -22
  501. data/ext/couchbase/core/operations/management/role_get_all.cxx +24 -22
  502. data/ext/couchbase/core/operations/management/role_get_all.hxx +13 -11
  503. data/ext/couchbase/core/operations/management/scope_create.cxx +38 -36
  504. data/ext/couchbase/core/operations/management/scope_create.hxx +15 -13
  505. data/ext/couchbase/core/operations/management/scope_drop.cxx +33 -32
  506. data/ext/couchbase/core/operations/management/scope_drop.hxx +15 -13
  507. data/ext/couchbase/core/operations/management/scope_get_all.cxx +27 -25
  508. data/ext/couchbase/core/operations/management/scope_get_all.hxx +14 -12
  509. data/ext/couchbase/core/operations/management/search_get_stats.cxx +12 -10
  510. data/ext/couchbase/core/operations/management/search_get_stats.hxx +13 -11
  511. data/ext/couchbase/core/operations/management/search_index_analyze_document.cxx +72 -67
  512. data/ext/couchbase/core/operations/management/search_index_analyze_document.hxx +20 -18
  513. data/ext/couchbase/core/operations/management/search_index_control_ingest.cxx +62 -59
  514. data/ext/couchbase/core/operations/management/search_index_control_ingest.hxx +19 -16
  515. data/ext/couchbase/core/operations/management/search_index_control_plan_freeze.cxx +62 -59
  516. data/ext/couchbase/core/operations/management/search_index_control_plan_freeze.hxx +19 -17
  517. data/ext/couchbase/core/operations/management/search_index_control_query.cxx +62 -59
  518. data/ext/couchbase/core/operations/management/search_index_control_query.hxx +19 -16
  519. data/ext/couchbase/core/operations/management/search_index_drop.cxx +58 -55
  520. data/ext/couchbase/core/operations/management/search_index_drop.hxx +18 -15
  521. data/ext/couchbase/core/operations/management/search_index_get.cxx +59 -56
  522. data/ext/couchbase/core/operations/management/search_index_get.hxx +18 -16
  523. data/ext/couchbase/core/operations/management/search_index_get_all.cxx +51 -46
  524. data/ext/couchbase/core/operations/management/search_index_get_all.hxx +18 -15
  525. data/ext/couchbase/core/operations/management/search_index_get_documents_count.cxx +66 -61
  526. data/ext/couchbase/core/operations/management/search_index_get_documents_count.hxx +19 -17
  527. data/ext/couchbase/core/operations/management/search_index_get_stats.cxx +38 -36
  528. data/ext/couchbase/core/operations/management/search_index_get_stats.hxx +17 -14
  529. data/ext/couchbase/core/operations/management/search_index_upsert.cxx +98 -95
  530. data/ext/couchbase/core/operations/management/search_index_upsert.hxx +20 -17
  531. data/ext/couchbase/core/operations/management/user_drop.cxx +18 -17
  532. data/ext/couchbase/core/operations/management/user_drop.hxx +16 -12
  533. data/ext/couchbase/core/operations/management/user_get.cxx +25 -23
  534. data/ext/couchbase/core/operations/management/user_get.hxx +17 -13
  535. data/ext/couchbase/core/operations/management/user_get_all.cxx +24 -22
  536. data/ext/couchbase/core/operations/management/user_get_all.hxx +16 -12
  537. data/ext/couchbase/core/operations/management/user_upsert.cxx +63 -60
  538. data/ext/couchbase/core/operations/management/user_upsert.hxx +17 -13
  539. data/ext/couchbase/core/operations/management/view_index_drop.cxx +16 -12
  540. data/ext/couchbase/core/operations/management/view_index_drop.hxx +15 -13
  541. data/ext/couchbase/core/operations/management/view_index_get.cxx +40 -35
  542. data/ext/couchbase/core/operations/management/view_index_get.hxx +16 -14
  543. data/ext/couchbase/core/operations/management/view_index_get_all.cxx +73 -69
  544. data/ext/couchbase/core/operations/management/view_index_get_all.hxx +16 -13
  545. data/ext/couchbase/core/operations/management/view_index_upsert.cxx +39 -35
  546. data/ext/couchbase/core/operations/management/view_index_upsert.hxx +15 -12
  547. data/ext/couchbase/core/origin.cxx +259 -249
  548. data/ext/couchbase/core/origin.hxx +55 -49
  549. data/ext/couchbase/core/pending_operation.hxx +3 -3
  550. data/ext/couchbase/core/ping_collector.hxx +3 -3
  551. data/ext/couchbase/core/ping_options.hxx +30 -30
  552. data/ext/couchbase/core/ping_reporter.hxx +3 -3
  553. data/ext/couchbase/core/platform/backtrace.c +100 -91
  554. data/ext/couchbase/core/platform/base64.cc +135 -134
  555. data/ext/couchbase/core/platform/dirutils.cc +66 -63
  556. data/ext/couchbase/core/platform/random.cc +43 -42
  557. data/ext/couchbase/core/platform/random.h +4 -4
  558. data/ext/couchbase/core/platform/string_hex.cc +42 -40
  559. data/ext/couchbase/core/platform/terminate_handler.cc +54 -52
  560. data/ext/couchbase/core/platform/uuid.cc +47 -47
  561. data/ext/couchbase/core/protocol/client_opcode.hxx +336 -327
  562. data/ext/couchbase/core/protocol/client_opcode_fmt.hxx +291 -291
  563. data/ext/couchbase/core/protocol/client_request.cxx +13 -10
  564. data/ext/couchbase/core/protocol/client_request.hxx +133 -130
  565. data/ext/couchbase/core/protocol/client_response.cxx +40 -40
  566. data/ext/couchbase/core/protocol/client_response.hxx +153 -150
  567. data/ext/couchbase/core/protocol/cmd_append.cxx +24 -23
  568. data/ext/couchbase/core/protocol/cmd_append.hxx +65 -65
  569. data/ext/couchbase/core/protocol/cmd_cluster_map_change_notification.cxx +25 -21
  570. data/ext/couchbase/core/protocol/cmd_cluster_map_change_notification.hxx +33 -25
  571. data/ext/couchbase/core/protocol/cmd_decrement.cxx +38 -38
  572. data/ext/couchbase/core/protocol/cmd_decrement.hxx +87 -87
  573. data/ext/couchbase/core/protocol/cmd_get.cxx +17 -17
  574. data/ext/couchbase/core/protocol/cmd_get.hxx +59 -59
  575. data/ext/couchbase/core/protocol/cmd_get_and_lock.cxx +20 -20
  576. data/ext/couchbase/core/protocol/cmd_get_and_lock.hxx +72 -72
  577. data/ext/couchbase/core/protocol/cmd_get_and_touch.cxx +20 -20
  578. data/ext/couchbase/core/protocol/cmd_get_and_touch.hxx +72 -72
  579. data/ext/couchbase/core/protocol/cmd_get_cluster_config.cxx +46 -39
  580. data/ext/couchbase/core/protocol/cmd_get_cluster_config.hxx +57 -49
  581. data/ext/couchbase/core/protocol/cmd_get_collection_id.cxx +17 -17
  582. data/ext/couchbase/core/protocol/cmd_get_collection_id.hxx +59 -59
  583. data/ext/couchbase/core/protocol/cmd_get_collections_manifest.cxx +16 -14
  584. data/ext/couchbase/core/protocol/cmd_get_collections_manifest.hxx +39 -39
  585. data/ext/couchbase/core/protocol/cmd_get_error_map.cxx +18 -17
  586. data/ext/couchbase/core/protocol/cmd_get_error_map.hxx +62 -62
  587. data/ext/couchbase/core/protocol/cmd_get_meta.cxx +24 -23
  588. data/ext/couchbase/core/protocol/cmd_get_meta.hxx +81 -79
  589. data/ext/couchbase/core/protocol/cmd_get_replica.cxx +23 -23
  590. data/ext/couchbase/core/protocol/cmd_get_replica.hxx +44 -44
  591. data/ext/couchbase/core/protocol/cmd_hello.cxx +28 -27
  592. data/ext/couchbase/core/protocol/cmd_hello.hxx +106 -105
  593. data/ext/couchbase/core/protocol/cmd_increment.cxx +38 -38
  594. data/ext/couchbase/core/protocol/cmd_increment.hxx +87 -87
  595. data/ext/couchbase/core/protocol/cmd_info.hxx +3 -3
  596. data/ext/couchbase/core/protocol/cmd_insert.cxx +27 -27
  597. data/ext/couchbase/core/protocol/cmd_insert.hxx +81 -81
  598. data/ext/couchbase/core/protocol/cmd_lookup_in.cxx +54 -51
  599. data/ext/couchbase/core/protocol/cmd_lookup_in.hxx +90 -90
  600. data/ext/couchbase/core/protocol/cmd_lookup_in_replica.cxx +54 -51
  601. data/ext/couchbase/core/protocol/cmd_lookup_in_replica.hxx +88 -88
  602. data/ext/couchbase/core/protocol/cmd_mutate_in.cxx +105 -97
  603. data/ext/couchbase/core/protocol/cmd_mutate_in.hxx +161 -153
  604. data/ext/couchbase/core/protocol/cmd_noop.cxx +4 -4
  605. data/ext/couchbase/core/protocol/cmd_noop.hxx +32 -32
  606. data/ext/couchbase/core/protocol/cmd_observe_seqno.cxx +36 -34
  607. data/ext/couchbase/core/protocol/cmd_observe_seqno.hxx +89 -89
  608. data/ext/couchbase/core/protocol/cmd_prepend.cxx +22 -22
  609. data/ext/couchbase/core/protocol/cmd_prepend.hxx +63 -63
  610. data/ext/couchbase/core/protocol/cmd_remove.cxx +23 -23
  611. data/ext/couchbase/core/protocol/cmd_remove.hxx +54 -54
  612. data/ext/couchbase/core/protocol/cmd_replace.cxx +28 -28
  613. data/ext/couchbase/core/protocol/cmd_replace.hxx +88 -88
  614. data/ext/couchbase/core/protocol/cmd_sasl_auth.cxx +17 -15
  615. data/ext/couchbase/core/protocol/cmd_sasl_auth.hxx +56 -56
  616. data/ext/couchbase/core/protocol/cmd_sasl_list_mechs.cxx +24 -19
  617. data/ext/couchbase/core/protocol/cmd_sasl_list_mechs.hxx +39 -39
  618. data/ext/couchbase/core/protocol/cmd_sasl_step.cxx +17 -15
  619. data/ext/couchbase/core/protocol/cmd_sasl_step.hxx +56 -56
  620. data/ext/couchbase/core/protocol/cmd_select_bucket.cxx +6 -6
  621. data/ext/couchbase/core/protocol/cmd_select_bucket.hxx +36 -36
  622. data/ext/couchbase/core/protocol/cmd_touch.cxx +8 -8
  623. data/ext/couchbase/core/protocol/cmd_touch.hxx +38 -38
  624. data/ext/couchbase/core/protocol/cmd_unlock.cxx +5 -5
  625. data/ext/couchbase/core/protocol/cmd_unlock.hxx +36 -36
  626. data/ext/couchbase/core/protocol/cmd_upsert.cxx +28 -28
  627. data/ext/couchbase/core/protocol/cmd_upsert.hxx +83 -83
  628. data/ext/couchbase/core/protocol/datatype.hxx +19 -18
  629. data/ext/couchbase/core/protocol/frame_info_id.hxx +108 -103
  630. data/ext/couchbase/core/protocol/frame_info_id_fmt.hxx +45 -45
  631. data/ext/couchbase/core/protocol/frame_info_utils.cxx +24 -21
  632. data/ext/couchbase/core/protocol/frame_info_utils.hxx +3 -1
  633. data/ext/couchbase/core/protocol/hello_feature.hxx +211 -175
  634. data/ext/couchbase/core/protocol/hello_feature_fmt.hxx +93 -90
  635. data/ext/couchbase/core/protocol/magic.hxx +24 -24
  636. data/ext/couchbase/core/protocol/magic_fmt.hxx +30 -30
  637. data/ext/couchbase/core/protocol/server_opcode.hxx +11 -11
  638. data/ext/couchbase/core/protocol/server_opcode_fmt.hxx +18 -18
  639. data/ext/couchbase/core/protocol/server_request.hxx +90 -86
  640. data/ext/couchbase/core/protocol/status.cxx +138 -138
  641. data/ext/couchbase/core/protocol/status.hxx +86 -86
  642. data/ext/couchbase/core/query_context.hxx +44 -43
  643. data/ext/couchbase/core/range_scan_load_balancer.cxx +51 -50
  644. data/ext/couchbase/core/range_scan_load_balancer.hxx +26 -25
  645. data/ext/couchbase/core/range_scan_options.cxx +2 -2
  646. data/ext/couchbase/core/range_scan_options.hxx +62 -59
  647. data/ext/couchbase/core/range_scan_orchestrator.cxx +515 -470
  648. data/ext/couchbase/core/range_scan_orchestrator.hxx +23 -18
  649. data/ext/couchbase/core/range_scan_orchestrator_options.hxx +10 -10
  650. data/ext/couchbase/core/resource_units.hxx +2 -2
  651. data/ext/couchbase/core/response_handler.hxx +8 -8
  652. data/ext/couchbase/core/retry_orchestrator.cxx +27 -19
  653. data/ext/couchbase/core/retry_orchestrator.hxx +3 -2
  654. data/ext/couchbase/core/sasl/client.cc +22 -18
  655. data/ext/couchbase/core/sasl/client.h +66 -62
  656. data/ext/couchbase/core/sasl/context.cc +4 -4
  657. data/ext/couchbase/core/sasl/context.h +19 -19
  658. data/ext/couchbase/core/sasl/error.h +12 -1
  659. data/ext/couchbase/core/sasl/error_fmt.h +42 -42
  660. data/ext/couchbase/core/sasl/mechanism.cc +13 -10
  661. data/ext/couchbase/core/sasl/mechanism.h +8 -3
  662. data/ext/couchbase/core/sasl/plain/plain.cc +8 -8
  663. data/ext/couchbase/core/sasl/plain/plain.h +25 -24
  664. data/ext/couchbase/core/sasl/scram-sha/scram-sha.cc +225 -218
  665. data/ext/couchbase/core/sasl/scram-sha/scram-sha.h +133 -115
  666. data/ext/couchbase/core/sasl/scram-sha/stringutils.cc +20 -20
  667. data/ext/couchbase/core/scan_result.cxx +38 -38
  668. data/ext/couchbase/core/scan_result.hxx +16 -16
  669. data/ext/couchbase/core/search_highlight_style.hxx +4 -1
  670. data/ext/couchbase/core/search_query_options.cxx +21 -21
  671. data/ext/couchbase/core/search_query_options.hxx +19 -18
  672. data/ext/couchbase/core/search_scan_consistency.hxx +3 -1
  673. data/ext/couchbase/core/seed_config.cxx +10 -7
  674. data/ext/couchbase/core/seed_config.hxx +8 -8
  675. data/ext/couchbase/core/service_type.hxx +7 -7
  676. data/ext/couchbase/core/service_type_fmt.hxx +33 -33
  677. data/ext/couchbase/core/stats_options.hxx +13 -13
  678. data/ext/couchbase/core/subdoc_options.hxx +60 -58
  679. data/ext/couchbase/core/tls_verify_mode.hxx +2 -2
  680. data/ext/couchbase/core/topology/capabilities.hxx +83 -83
  681. data/ext/couchbase/core/topology/capabilities_fmt.hxx +111 -111
  682. data/ext/couchbase/core/topology/collections_manifest.hxx +14 -14
  683. data/ext/couchbase/core/topology/collections_manifest_fmt.hxx +23 -21
  684. data/ext/couchbase/core/topology/collections_manifest_json.hxx +26 -25
  685. data/ext/couchbase/core/topology/configuration.cxx +213 -192
  686. data/ext/couchbase/core/topology/configuration.hxx +104 -91
  687. data/ext/couchbase/core/topology/configuration_fmt.hxx +131 -128
  688. data/ext/couchbase/core/topology/configuration_json.hxx +276 -242
  689. data/ext/couchbase/core/topology/error_map.hxx +5 -5
  690. data/ext/couchbase/core/topology/error_map_json.hxx +65 -60
  691. data/ext/couchbase/core/tracing/constants.hxx +153 -153
  692. data/ext/couchbase/core/tracing/noop_tracer.hxx +29 -28
  693. data/ext/couchbase/core/tracing/threshold_logging_options.hxx +30 -30
  694. data/ext/couchbase/core/tracing/threshold_logging_tracer.cxx +354 -344
  695. data/ext/couchbase/core/tracing/threshold_logging_tracer.hxx +12 -12
  696. data/ext/couchbase/core/transactions/active_transaction_record.cxx +153 -33
  697. data/ext/couchbase/core/transactions/active_transaction_record.hxx +30 -118
  698. data/ext/couchbase/core/transactions/async_attempt_context.cxx +8 -2
  699. data/ext/couchbase/core/transactions/async_attempt_context.hxx +163 -127
  700. data/ext/couchbase/core/transactions/atr_cleanup_entry.cxx +358 -334
  701. data/ext/couchbase/core/transactions/atr_ids.cxx +270 -185
  702. data/ext/couchbase/core/transactions/atr_ids.hxx +4 -4
  703. data/ext/couchbase/core/transactions/attempt_context.cxx +9 -5
  704. data/ext/couchbase/core/transactions/attempt_context.hxx +194 -154
  705. data/ext/couchbase/core/transactions/attempt_context_impl.cxx +3278 -2159
  706. data/ext/couchbase/core/transactions/attempt_context_impl.hxx +446 -573
  707. data/ext/couchbase/core/transactions/attempt_context_testing_hooks.cxx +15 -10
  708. data/ext/couchbase/core/transactions/attempt_context_testing_hooks.hxx +58 -49
  709. data/ext/couchbase/core/transactions/attempt_state.hxx +72 -72
  710. data/ext/couchbase/core/transactions/binary.cxx +3 -3
  711. data/ext/couchbase/core/transactions/cleanup_testing_hooks.cxx +2 -2
  712. data/ext/couchbase/core/transactions/cleanup_testing_hooks.hxx +28 -24
  713. data/ext/couchbase/core/transactions/document_metadata.hxx +68 -68
  714. data/ext/couchbase/core/transactions/durability_level.hxx +53 -53
  715. data/ext/couchbase/core/transactions/error_class.hxx +12 -12
  716. data/ext/couchbase/core/transactions/error_list.hxx +22 -22
  717. data/ext/couchbase/core/transactions/exceptions.cxx +167 -114
  718. data/ext/couchbase/core/transactions/exceptions.hxx +170 -139
  719. data/ext/couchbase/core/transactions/exceptions_fmt.hxx +105 -0
  720. data/ext/couchbase/core/transactions/forward_compat.cxx +220 -0
  721. data/ext/couchbase/core/transactions/forward_compat.hxx +63 -207
  722. data/ext/couchbase/core/transactions/internal/atr_cleanup_entry.hxx +110 -102
  723. data/ext/couchbase/core/transactions/internal/atr_entry.hxx +144 -144
  724. data/ext/couchbase/core/transactions/internal/client_record.hxx +53 -50
  725. data/ext/couchbase/core/transactions/internal/doc_record.cxx +5 -5
  726. data/ext/couchbase/core/transactions/internal/doc_record.hxx +38 -35
  727. data/ext/couchbase/core/transactions/internal/doc_record_fmt.hxx +17 -16
  728. data/ext/couchbase/core/transactions/internal/exceptions_internal.hxx +238 -281
  729. data/ext/couchbase/core/transactions/internal/exceptions_internal_fmt.hxx +103 -0
  730. data/ext/couchbase/core/transactions/internal/logging.hxx +52 -29
  731. data/ext/couchbase/core/transactions/internal/transaction_attempt.hxx +3 -3
  732. data/ext/couchbase/core/transactions/internal/transaction_context.hxx +136 -120
  733. data/ext/couchbase/core/transactions/internal/transaction_fields.hxx +2 -1
  734. data/ext/couchbase/core/transactions/internal/transactions_cleanup.hxx +127 -122
  735. data/ext/couchbase/core/transactions/internal/utils.hxx +244 -219
  736. data/ext/couchbase/core/transactions/result.cxx +41 -40
  737. data/ext/couchbase/core/transactions/result.hxx +143 -141
  738. data/ext/couchbase/core/transactions/result_fmt.hxx +21 -20
  739. data/ext/couchbase/core/transactions/staged_mutation.cxx +759 -627
  740. data/ext/couchbase/core/transactions/staged_mutation.hxx +175 -156
  741. data/ext/couchbase/core/transactions/transaction_context.cxx +231 -179
  742. data/ext/couchbase/core/transactions/transaction_get_result.cxx +185 -198
  743. data/ext/couchbase/core/transactions/transaction_get_result.hxx +207 -222
  744. data/ext/couchbase/core/transactions/transaction_keyspace.cxx +15 -11
  745. data/ext/couchbase/core/transactions/transaction_links.cxx +11 -7
  746. data/ext/couchbase/core/transactions/transaction_links.hxx +222 -201
  747. data/ext/couchbase/core/transactions/transaction_options.cxx +44 -41
  748. data/ext/couchbase/core/transactions/transactions.cxx +167 -125
  749. data/ext/couchbase/core/transactions/transactions_cleanup.cxx +491 -424
  750. data/ext/couchbase/core/transactions/transactions_config.cxx +25 -19
  751. data/ext/couchbase/core/transactions/uid_generator.cxx +3 -3
  752. data/ext/couchbase/core/transactions/uid_generator.hxx +2 -2
  753. data/ext/couchbase/core/transactions/utils.cxx +82 -69
  754. data/ext/couchbase/core/transactions/waitable_op_list.hxx +154 -140
  755. data/ext/couchbase/core/transactions.hxx +184 -180
  756. data/ext/couchbase/core/utils/binary.cxx +3 -3
  757. data/ext/couchbase/core/utils/binary.hxx +19 -15
  758. data/ext/couchbase/core/utils/byteswap.hxx +17 -17
  759. data/ext/couchbase/core/utils/connection_string.cxx +395 -328
  760. data/ext/couchbase/core/utils/connection_string.hxx +37 -36
  761. data/ext/couchbase/core/utils/crc32.hxx +42 -34
  762. data/ext/couchbase/core/utils/duration_parser.cxx +142 -133
  763. data/ext/couchbase/core/utils/duration_parser.hxx +9 -9
  764. data/ext/couchbase/core/utils/join_strings.hxx +24 -24
  765. data/ext/couchbase/core/utils/json.cxx +234 -228
  766. data/ext/couchbase/core/utils/json.hxx +12 -12
  767. data/ext/couchbase/core/utils/json_stream_control.hxx +8 -8
  768. data/ext/couchbase/core/utils/json_streaming_lexer.cxx +288 -263
  769. data/ext/couchbase/core/utils/json_streaming_lexer.hxx +20 -17
  770. data/ext/couchbase/core/utils/keyspace.hxx +22 -21
  771. data/ext/couchbase/core/utils/movable_function.hxx +78 -76
  772. data/ext/couchbase/core/utils/mutation_token.cxx +7 -3
  773. data/ext/couchbase/core/utils/mutation_token.hxx +3 -1
  774. data/ext/couchbase/core/utils/name_codec.hxx +13 -13
  775. data/ext/couchbase/core/utils/split_string.cxx +9 -9
  776. data/ext/couchbase/core/utils/split_string.hxx +2 -2
  777. data/ext/couchbase/core/utils/unsigned_leb128.hxx +92 -88
  778. data/ext/couchbase/core/utils/url_codec.cxx +301 -297
  779. data/ext/couchbase/core/utils/url_codec.hxx +35 -35
  780. data/ext/couchbase/core/vector_query_combination.hxx +4 -1
  781. data/ext/couchbase/core/view_on_error.hxx +4 -3
  782. data/ext/couchbase/core/view_query_options.cxx +21 -21
  783. data/ext/couchbase/core/view_query_options.hxx +23 -22
  784. data/ext/couchbase/core/view_scan_consistency.hxx +3 -3
  785. data/ext/couchbase/core/view_sort_order.hxx +4 -1
  786. data/ext/couchbase/core/wait_until_ready_options.hxx +11 -10
  787. data/ext/couchbase/couchbase/allow_querying_search_index_options.hxx +11 -11
  788. data/ext/couchbase/couchbase/analytics_index_manager.hxx +423 -405
  789. data/ext/couchbase/couchbase/analytics_meta_data.hxx +105 -105
  790. data/ext/couchbase/couchbase/analytics_metrics.hxx +120 -118
  791. data/ext/couchbase/couchbase/analytics_options.hxx +318 -292
  792. data/ext/couchbase/couchbase/analytics_result.hxx +56 -55
  793. data/ext/couchbase/couchbase/analytics_scan_consistency.hxx +24 -21
  794. data/ext/couchbase/couchbase/analytics_status.hxx +10 -10
  795. data/ext/couchbase/couchbase/analytics_warning.hxx +44 -43
  796. data/ext/couchbase/couchbase/analyze_document_options.hxx +9 -9
  797. data/ext/couchbase/couchbase/append_options.hxx +51 -47
  798. data/ext/couchbase/couchbase/behavior_options.hxx +75 -69
  799. data/ext/couchbase/couchbase/best_effort_retry_strategy.hxx +12 -10
  800. data/ext/couchbase/couchbase/binary_collection.hxx +213 -183
  801. data/ext/couchbase/couchbase/boolean_field_query.hxx +38 -38
  802. data/ext/couchbase/couchbase/boolean_query.hxx +166 -157
  803. data/ext/couchbase/couchbase/bucket.hxx +69 -68
  804. data/ext/couchbase/couchbase/bucket_manager.hxx +97 -88
  805. data/ext/couchbase/couchbase/build_query_index_options.hxx +22 -21
  806. data/ext/couchbase/couchbase/cas.hxx +74 -73
  807. data/ext/couchbase/couchbase/certificate_authenticator.hxx +10 -10
  808. data/ext/couchbase/couchbase/cluster.hxx +266 -310
  809. data/ext/couchbase/couchbase/cluster_options.hxx +235 -241
  810. data/ext/couchbase/couchbase/codec/binary_noop_serializer.hxx +11 -11
  811. data/ext/couchbase/couchbase/codec/codec_flags.hxx +39 -35
  812. data/ext/couchbase/couchbase/codec/encoded_value.hxx +15 -2
  813. data/ext/couchbase/couchbase/codec/json_transcoder.hxx +17 -15
  814. data/ext/couchbase/couchbase/codec/raw_binary_transcoder.hxx +19 -17
  815. data/ext/couchbase/couchbase/codec/raw_json_transcoder.hxx +31 -24
  816. data/ext/couchbase/couchbase/codec/raw_string_transcoder.hxx +20 -18
  817. data/ext/couchbase/couchbase/codec/tao_json_serializer.hxx +38 -30
  818. data/ext/couchbase/couchbase/collection.hxx +1007 -902
  819. data/ext/couchbase/couchbase/collection_manager.hxx +115 -107
  820. data/ext/couchbase/couchbase/collection_query_index_manager.hxx +200 -188
  821. data/ext/couchbase/couchbase/common_durability_options.hxx +68 -62
  822. data/ext/couchbase/couchbase/common_options.hxx +67 -67
  823. data/ext/couchbase/couchbase/compression_options.hxx +33 -33
  824. data/ext/couchbase/couchbase/configuration_profile.hxx +12 -11
  825. data/ext/couchbase/couchbase/configuration_profiles_registry.hxx +24 -22
  826. data/ext/couchbase/couchbase/conjunction_query.hxx +47 -45
  827. data/ext/couchbase/couchbase/connect_link_analytics_options.hxx +74 -72
  828. data/ext/couchbase/couchbase/counter_result.hxx +32 -32
  829. data/ext/couchbase/couchbase/create_bucket_options.hxx +9 -10
  830. data/ext/couchbase/couchbase/create_collection_options.hxx +35 -34
  831. data/ext/couchbase/couchbase/create_dataset_analytics_options.hxx +76 -76
  832. data/ext/couchbase/couchbase/create_dataverse_analytics_options.hxx +44 -44
  833. data/ext/couchbase/couchbase/create_index_analytics_options.hxx +60 -60
  834. data/ext/couchbase/couchbase/create_link_analytics_options.hxx +25 -25
  835. data/ext/couchbase/couchbase/create_primary_query_index_options.hxx +95 -94
  836. data/ext/couchbase/couchbase/create_query_index_options.hxx +97 -96
  837. data/ext/couchbase/couchbase/create_scope_options.hxx +9 -9
  838. data/ext/couchbase/couchbase/date_range.hxx +29 -27
  839. data/ext/couchbase/couchbase/date_range_facet.hxx +20 -20
  840. data/ext/couchbase/couchbase/date_range_facet_result.hxx +14 -14
  841. data/ext/couchbase/couchbase/date_range_query.hxx +219 -205
  842. data/ext/couchbase/couchbase/decrement_options.hxx +93 -91
  843. data/ext/couchbase/couchbase/diagnostics_options.hxx +42 -41
  844. data/ext/couchbase/couchbase/diagnostics_result.hxx +82 -83
  845. data/ext/couchbase/couchbase/disallow_querying_search_index_options.hxx +11 -10
  846. data/ext/couchbase/couchbase/disconnect_link_analytics_options.hxx +62 -62
  847. data/ext/couchbase/couchbase/disjunction_query.hxx +61 -60
  848. data/ext/couchbase/couchbase/dns_options.hxx +30 -30
  849. data/ext/couchbase/couchbase/doc_id_query.hxx +69 -69
  850. data/ext/couchbase/couchbase/drop_bucket_options.hxx +9 -9
  851. data/ext/couchbase/couchbase/drop_collection_options.hxx +9 -9
  852. data/ext/couchbase/couchbase/drop_dataset_analytics_options.hxx +60 -60
  853. data/ext/couchbase/couchbase/drop_dataverse_analytics_options.hxx +44 -44
  854. data/ext/couchbase/couchbase/drop_index_analytics_options.hxx +60 -60
  855. data/ext/couchbase/couchbase/drop_link_analytics_options.hxx +25 -25
  856. data/ext/couchbase/couchbase/drop_primary_query_index_options.hxx +58 -58
  857. data/ext/couchbase/couchbase/drop_query_index_options.hxx +44 -44
  858. data/ext/couchbase/couchbase/drop_scope_options.hxx +9 -9
  859. data/ext/couchbase/couchbase/drop_search_index_options.hxx +9 -9
  860. data/ext/couchbase/couchbase/durability_level.hxx +32 -29
  861. data/ext/couchbase/couchbase/endpoint_diagnostics.hxx +171 -171
  862. data/ext/couchbase/couchbase/endpoint_ping_report.hxx +166 -169
  863. data/ext/couchbase/couchbase/error.hxx +51 -0
  864. data/ext/couchbase/couchbase/error_codes.hxx +975 -940
  865. data/ext/couchbase/couchbase/error_context.hxx +19 -152
  866. data/ext/couchbase/couchbase/exists_options.hxx +25 -24
  867. data/ext/couchbase/couchbase/exists_result.hxx +32 -32
  868. data/ext/couchbase/couchbase/fail_fast_retry_strategy.hxx +4 -4
  869. data/ext/couchbase/couchbase/flush_bucket_options.hxx +9 -9
  870. data/ext/couchbase/couchbase/fmt/analytics_scan_consistency.hxx +18 -18
  871. data/ext/couchbase/couchbase/fmt/analytics_status.hxx +42 -42
  872. data/ext/couchbase/couchbase/fmt/cas.hxx +10 -10
  873. data/ext/couchbase/couchbase/fmt/durability_level.hxx +24 -24
  874. data/ext/couchbase/couchbase/fmt/error.hxx +53 -0
  875. data/ext/couchbase/couchbase/fmt/error_context.hxx +43 -0
  876. data/ext/couchbase/couchbase/fmt/mutation_token.hxx +15 -11
  877. data/ext/couchbase/couchbase/fmt/query_profile.hxx +21 -21
  878. data/ext/couchbase/couchbase/fmt/query_scan_consistency.hxx +18 -18
  879. data/ext/couchbase/couchbase/fmt/query_status.hxx +42 -42
  880. data/ext/couchbase/couchbase/fmt/retry_reason.hxx +75 -75
  881. data/ext/couchbase/couchbase/fmt/search_scan_consistency.hxx +15 -15
  882. data/ext/couchbase/couchbase/fmt/tls_verify_mode.hxx +18 -18
  883. data/ext/couchbase/couchbase/fmt/transaction_keyspace.hxx +15 -11
  884. data/ext/couchbase/couchbase/fork_event.hxx +12 -12
  885. data/ext/couchbase/couchbase/freeze_plan_search_index_options.hxx +9 -9
  886. data/ext/couchbase/couchbase/geo_bounding_box_query.hxx +71 -64
  887. data/ext/couchbase/couchbase/geo_distance_query.hxx +73 -66
  888. data/ext/couchbase/couchbase/geo_point.hxx +2 -2
  889. data/ext/couchbase/couchbase/geo_polygon_query.hxx +40 -39
  890. data/ext/couchbase/couchbase/get_all_buckets_options.hxx +9 -9
  891. data/ext/couchbase/couchbase/get_all_datasets_analytics_options.hxx +25 -25
  892. data/ext/couchbase/couchbase/get_all_indexes_analytics_options.hxx +26 -25
  893. data/ext/couchbase/couchbase/get_all_query_indexes_options.hxx +27 -25
  894. data/ext/couchbase/couchbase/get_all_replicas_options.hxx +49 -26
  895. data/ext/couchbase/couchbase/get_all_scopes_options.hxx +9 -9
  896. data/ext/couchbase/couchbase/get_all_search_indexes_options.hxx +9 -9
  897. data/ext/couchbase/couchbase/get_and_lock_options.hxx +25 -24
  898. data/ext/couchbase/couchbase/get_and_touch_options.hxx +25 -24
  899. data/ext/couchbase/couchbase/get_any_replica_options.hxx +49 -26
  900. data/ext/couchbase/couchbase/get_bucket_options.hxx +9 -9
  901. data/ext/couchbase/couchbase/get_indexed_search_index_options.hxx +9 -9
  902. data/ext/couchbase/couchbase/get_links_analytics_options.hxx +74 -74
  903. data/ext/couchbase/couchbase/get_options.hxx +63 -60
  904. data/ext/couchbase/couchbase/get_pending_mutations_analytics_options.hxx +30 -28
  905. data/ext/couchbase/couchbase/get_replica_result.hxx +79 -75
  906. data/ext/couchbase/couchbase/get_result.hxx +86 -80
  907. data/ext/couchbase/couchbase/get_search_index_options.hxx +9 -9
  908. data/ext/couchbase/couchbase/highlight_style.hxx +14 -14
  909. data/ext/couchbase/couchbase/increment_options.hxx +94 -91
  910. data/ext/couchbase/couchbase/insert_options.hxx +62 -59
  911. data/ext/couchbase/couchbase/ip_protocol.hxx +3 -3
  912. data/ext/couchbase/couchbase/logger.hxx +51 -0
  913. data/ext/couchbase/couchbase/lookup_in_all_replicas_options.hxx +54 -43
  914. data/ext/couchbase/couchbase/lookup_in_any_replica_options.hxx +54 -44
  915. data/ext/couchbase/couchbase/lookup_in_options.hxx +40 -40
  916. data/ext/couchbase/couchbase/lookup_in_replica_result.hxx +38 -35
  917. data/ext/couchbase/couchbase/lookup_in_result.hxx +222 -216
  918. data/ext/couchbase/couchbase/lookup_in_specs.hxx +101 -101
  919. data/ext/couchbase/couchbase/management/analytics_dataset.hxx +16 -16
  920. data/ext/couchbase/couchbase/management/analytics_index.hxx +16 -16
  921. data/ext/couchbase/couchbase/management/analytics_link.hxx +193 -189
  922. data/ext/couchbase/couchbase/management/bucket_settings.hxx +91 -75
  923. data/ext/couchbase/couchbase/management/collection_spec.hxx +4 -4
  924. data/ext/couchbase/couchbase/management/query_index.hxx +10 -10
  925. data/ext/couchbase/couchbase/management/scope_spec.hxx +2 -2
  926. data/ext/couchbase/couchbase/management/search_index.hxx +9 -9
  927. data/ext/couchbase/couchbase/match_all_query.hxx +10 -9
  928. data/ext/couchbase/couchbase/match_none_query.hxx +10 -9
  929. data/ext/couchbase/couchbase/match_operator.hxx +15 -14
  930. data/ext/couchbase/couchbase/match_phrase_query.hxx +70 -65
  931. data/ext/couchbase/couchbase/match_query.hxx +115 -114
  932. data/ext/couchbase/couchbase/metrics/meter.hxx +33 -30
  933. data/ext/couchbase/couchbase/metrics/otel_meter.hxx +86 -74
  934. data/ext/couchbase/couchbase/metrics_options.hxx +34 -34
  935. data/ext/couchbase/couchbase/mutate_in_options.hxx +160 -149
  936. data/ext/couchbase/couchbase/mutate_in_result.hxx +130 -123
  937. data/ext/couchbase/couchbase/mutate_in_specs.hxx +473 -454
  938. data/ext/couchbase/couchbase/mutation_result.hxx +32 -32
  939. data/ext/couchbase/couchbase/mutation_state.hxx +35 -34
  940. data/ext/couchbase/couchbase/mutation_token.hxx +78 -78
  941. data/ext/couchbase/couchbase/network_options.hxx +101 -72
  942. data/ext/couchbase/couchbase/numeric_range.hxx +26 -26
  943. data/ext/couchbase/couchbase/numeric_range_facet.hxx +20 -20
  944. data/ext/couchbase/couchbase/numeric_range_facet_result.hxx +14 -14
  945. data/ext/couchbase/couchbase/numeric_range_query.hxx +97 -95
  946. data/ext/couchbase/couchbase/password_authenticator.hxx +17 -17
  947. data/ext/couchbase/couchbase/pause_ingest_search_index_options.hxx +11 -10
  948. data/ext/couchbase/couchbase/persist_to.hxx +45 -44
  949. data/ext/couchbase/couchbase/phrase_query.hxx +69 -65
  950. data/ext/couchbase/couchbase/ping_options.hxx +55 -54
  951. data/ext/couchbase/couchbase/ping_result.hxx +79 -77
  952. data/ext/couchbase/couchbase/prefix_query.hxx +43 -40
  953. data/ext/couchbase/couchbase/prepend_options.hxx +51 -47
  954. data/ext/couchbase/couchbase/query_index_manager.hxx +207 -199
  955. data/ext/couchbase/couchbase/query_meta_data.hxx +120 -120
  956. data/ext/couchbase/couchbase/query_metrics.hxx +135 -133
  957. data/ext/couchbase/couchbase/query_options.hxx +518 -493
  958. data/ext/couchbase/couchbase/query_profile.hxx +29 -26
  959. data/ext/couchbase/couchbase/query_result.hxx +56 -55
  960. data/ext/couchbase/couchbase/query_scan_consistency.hxx +24 -21
  961. data/ext/couchbase/couchbase/query_status.hxx +10 -10
  962. data/ext/couchbase/couchbase/query_string_query.hxx +34 -29
  963. data/ext/couchbase/couchbase/query_warning.hxx +75 -71
  964. data/ext/couchbase/couchbase/read_preference.hxx +58 -0
  965. data/ext/couchbase/couchbase/regexp_query.hxx +40 -39
  966. data/ext/couchbase/couchbase/remove_options.hxx +51 -47
  967. data/ext/couchbase/couchbase/replace_link_analytics_options.hxx +25 -25
  968. data/ext/couchbase/couchbase/replace_options.hxx +112 -104
  969. data/ext/couchbase/couchbase/replicate_to.hxx +28 -28
  970. data/ext/couchbase/couchbase/result.hxx +28 -28
  971. data/ext/couchbase/couchbase/resume_ingest_search_index_options.hxx +11 -10
  972. data/ext/couchbase/couchbase/retry_action.hxx +10 -10
  973. data/ext/couchbase/couchbase/retry_reason.hxx +53 -51
  974. data/ext/couchbase/couchbase/retry_request.hxx +7 -7
  975. data/ext/couchbase/couchbase/retry_strategy.hxx +4 -4
  976. data/ext/couchbase/couchbase/scan_options.hxx +114 -108
  977. data/ext/couchbase/couchbase/scan_result.hxx +97 -96
  978. data/ext/couchbase/couchbase/scan_result_item.hxx +120 -118
  979. data/ext/couchbase/couchbase/scan_type.hxx +237 -232
  980. data/ext/couchbase/couchbase/scope.hxx +164 -157
  981. data/ext/couchbase/couchbase/scope_search_index_manager.hxx +263 -238
  982. data/ext/couchbase/couchbase/search_date_range.hxx +32 -29
  983. data/ext/couchbase/couchbase/search_facet.hxx +25 -25
  984. data/ext/couchbase/couchbase/search_facet_result.hxx +11 -11
  985. data/ext/couchbase/couchbase/search_geo_distance_units.hxx +11 -1
  986. data/ext/couchbase/couchbase/search_index_manager.hxx +261 -238
  987. data/ext/couchbase/couchbase/search_meta_data.hxx +37 -37
  988. data/ext/couchbase/couchbase/search_metrics.hxx +84 -83
  989. data/ext/couchbase/couchbase/search_numeric_range.hxx +32 -32
  990. data/ext/couchbase/couchbase/search_options.hxx +449 -435
  991. data/ext/couchbase/couchbase/search_query.hxx +32 -30
  992. data/ext/couchbase/couchbase/search_request.hxx +69 -68
  993. data/ext/couchbase/couchbase/search_result.hxx +29 -26
  994. data/ext/couchbase/couchbase/search_row.hxx +52 -52
  995. data/ext/couchbase/couchbase/search_row_location.hxx +20 -20
  996. data/ext/couchbase/couchbase/search_row_locations.hxx +39 -38
  997. data/ext/couchbase/couchbase/search_scan_consistency.hxx +11 -10
  998. data/ext/couchbase/couchbase/search_sort.hxx +20 -20
  999. data/ext/couchbase/couchbase/search_sort_field.hxx +77 -71
  1000. data/ext/couchbase/couchbase/search_sort_field_missing.hxx +2 -2
  1001. data/ext/couchbase/couchbase/search_sort_field_mode.hxx +3 -3
  1002. data/ext/couchbase/couchbase/search_sort_field_type.hxx +4 -4
  1003. data/ext/couchbase/couchbase/search_sort_geo_distance.hxx +41 -41
  1004. data/ext/couchbase/couchbase/search_sort_id.hxx +23 -23
  1005. data/ext/couchbase/couchbase/search_sort_score.hxx +23 -23
  1006. data/ext/couchbase/couchbase/search_term_range.hxx +17 -17
  1007. data/ext/couchbase/couchbase/security_options.hxx +50 -50
  1008. data/ext/couchbase/couchbase/service_type.hxx +34 -34
  1009. data/ext/couchbase/couchbase/store_semantics.hxx +28 -28
  1010. data/ext/couchbase/couchbase/subdoc/array_add_unique.hxx +54 -54
  1011. data/ext/couchbase/couchbase/subdoc/array_append.hxx +40 -40
  1012. data/ext/couchbase/couchbase/subdoc/array_insert.hxx +41 -41
  1013. data/ext/couchbase/couchbase/subdoc/array_prepend.hxx +41 -41
  1014. data/ext/couchbase/couchbase/subdoc/count.hxx +24 -24
  1015. data/ext/couchbase/couchbase/subdoc/counter.hxx +41 -41
  1016. data/ext/couchbase/couchbase/subdoc/exists.hxx +24 -24
  1017. data/ext/couchbase/couchbase/subdoc/get.hxx +45 -29
  1018. data/ext/couchbase/couchbase/subdoc/insert.hxx +70 -54
  1019. data/ext/couchbase/couchbase/subdoc/lookup_in_macro.hxx +13 -12
  1020. data/ext/couchbase/couchbase/subdoc/mutate_in_macro.hxx +7 -2
  1021. data/ext/couchbase/couchbase/subdoc/remove.hxx +24 -24
  1022. data/ext/couchbase/couchbase/subdoc/replace.hxx +55 -39
  1023. data/ext/couchbase/couchbase/subdoc/upsert.hxx +70 -54
  1024. data/ext/couchbase/couchbase/term_facet.hxx +16 -16
  1025. data/ext/couchbase/couchbase/term_facet_result.hxx +14 -14
  1026. data/ext/couchbase/couchbase/term_query.hxx +107 -104
  1027. data/ext/couchbase/couchbase/term_range_query.hxx +99 -96
  1028. data/ext/couchbase/couchbase/timeout_options.hxx +118 -112
  1029. data/ext/couchbase/couchbase/tls_verify_mode.hxx +2 -2
  1030. data/ext/couchbase/couchbase/touch_options.hxx +25 -24
  1031. data/ext/couchbase/couchbase/tracing/otel_tracer.hxx +45 -44
  1032. data/ext/couchbase/couchbase/tracing/request_span.hxx +34 -34
  1033. data/ext/couchbase/couchbase/tracing/request_tracer.hxx +27 -25
  1034. data/ext/couchbase/couchbase/tracing_options.hxx +147 -142
  1035. data/ext/couchbase/couchbase/transactions/async_attempt_context.hxx +149 -115
  1036. data/ext/couchbase/couchbase/transactions/attempt_context.hxx +146 -95
  1037. data/ext/couchbase/couchbase/transactions/transaction_get_result.hxx +52 -80
  1038. data/ext/couchbase/couchbase/transactions/transaction_keyspace.hxx +33 -29
  1039. data/ext/couchbase/couchbase/transactions/transaction_options.hxx +101 -96
  1040. data/ext/couchbase/couchbase/transactions/transaction_query_options.hxx +228 -223
  1041. data/ext/couchbase/couchbase/transactions/transaction_query_result.hxx +11 -12
  1042. data/ext/couchbase/couchbase/transactions/transaction_result.hxx +2 -3
  1043. data/ext/couchbase/couchbase/transactions/transactions_cleanup_config.hxx +105 -104
  1044. data/ext/couchbase/couchbase/transactions/transactions_config.hxx +191 -187
  1045. data/ext/couchbase/couchbase/transactions/transactions_query_config.hxx +32 -32
  1046. data/ext/couchbase/couchbase/transactions.hxx +56 -37
  1047. data/ext/couchbase/couchbase/unfreeze_plan_search_index_options.hxx +11 -10
  1048. data/ext/couchbase/couchbase/unlock_options.hxx +25 -24
  1049. data/ext/couchbase/couchbase/update_bucket_options.hxx +9 -9
  1050. data/ext/couchbase/couchbase/update_collection_options.hxx +35 -34
  1051. data/ext/couchbase/couchbase/upsert_options.hxx +85 -80
  1052. data/ext/couchbase/couchbase/upsert_search_index_options.hxx +9 -9
  1053. data/ext/couchbase/couchbase/vector_query.hxx +82 -62
  1054. data/ext/couchbase/couchbase/vector_search.hxx +51 -47
  1055. data/ext/couchbase/couchbase/vector_search_options.hxx +45 -41
  1056. data/ext/couchbase/couchbase/wan_development_configuration_profile.hxx +13 -13
  1057. data/ext/couchbase/couchbase/watch_query_indexes_options.hxx +41 -41
  1058. data/ext/couchbase/couchbase/wildcard_query.hxx +42 -41
  1059. data/ext/couchbase/third_party/expected/include/tl/expected.hpp +1746 -1584
  1060. data/ext/couchbase/third_party/jsonsl/jsonsl.c +2664 -2638
  1061. data/ext/couchbase/third_party/jsonsl/jsonsl.h +359 -342
  1062. data/ext/couchbase.cxx +43 -9568
  1063. data/ext/extconf.rb +5 -0
  1064. data/ext/rcb_analytics.cxx +1195 -0
  1065. data/ext/rcb_analytics.hxx +29 -0
  1066. data/ext/rcb_backend.cxx +530 -0
  1067. data/ext/rcb_backend.hxx +46 -0
  1068. data/ext/rcb_buckets.cxx +624 -0
  1069. data/ext/rcb_buckets.hxx +29 -0
  1070. data/ext/rcb_collections.cxx +377 -0
  1071. data/ext/rcb_collections.hxx +29 -0
  1072. data/ext/rcb_crud.cxx +1544 -0
  1073. data/ext/rcb_crud.hxx +29 -0
  1074. data/ext/rcb_diagnostics.cxx +264 -0
  1075. data/ext/rcb_diagnostics.hxx +29 -0
  1076. data/ext/rcb_exceptions.cxx +963 -0
  1077. data/ext/rcb_exceptions.hxx +111 -0
  1078. data/ext/rcb_extras.cxx +394 -0
  1079. data/ext/rcb_extras.hxx +29 -0
  1080. data/ext/rcb_logger.cxx +319 -0
  1081. data/ext/rcb_logger.hxx +36 -0
  1082. data/ext/rcb_multi.cxx +343 -0
  1083. data/ext/rcb_multi.hxx +29 -0
  1084. data/ext/rcb_query.cxx +1316 -0
  1085. data/ext/rcb_query.hxx +29 -0
  1086. data/ext/rcb_range_scan.cxx +358 -0
  1087. data/ext/rcb_range_scan.hxx +29 -0
  1088. data/ext/rcb_search.cxx +1216 -0
  1089. data/ext/rcb_search.hxx +29 -0
  1090. data/ext/rcb_users.cxx +636 -0
  1091. data/ext/rcb_users.hxx +29 -0
  1092. data/ext/rcb_utils.cxx +590 -0
  1093. data/ext/rcb_utils.hxx +564 -0
  1094. data/ext/rcb_version.cxx +137 -0
  1095. data/ext/rcb_version.hxx +34 -0
  1096. data/ext/rcb_views.cxx +485 -0
  1097. data/ext/rcb_views.hxx +29 -0
  1098. data/lib/active_support/cache/couchbase_store.rb +4 -1
  1099. data/lib/couchbase/analytics_options.rb +2 -0
  1100. data/lib/couchbase/authenticator.rb +2 -0
  1101. data/lib/couchbase/binary_collection.rb +2 -0
  1102. data/lib/couchbase/binary_collection_options.rb +2 -0
  1103. data/lib/couchbase/bucket.rb +2 -0
  1104. data/lib/couchbase/cluster.rb +2 -0
  1105. data/lib/couchbase/collection.rb +3 -1
  1106. data/lib/couchbase/collection_options.rb +2 -0
  1107. data/lib/couchbase/config_profiles.rb +2 -0
  1108. data/lib/couchbase/configuration.rb +2 -0
  1109. data/lib/couchbase/datastructures/couchbase_list.rb +4 -4
  1110. data/lib/couchbase/datastructures/couchbase_map.rb +4 -4
  1111. data/lib/couchbase/datastructures/couchbase_queue.rb +4 -4
  1112. data/lib/couchbase/datastructures/couchbase_set.rb +4 -4
  1113. data/lib/couchbase/datastructures.rb +2 -0
  1114. data/lib/couchbase/diagnostics.rb +2 -0
  1115. data/lib/couchbase/errors.rb +46 -8
  1116. data/lib/couchbase/json_transcoder.rb +2 -0
  1117. data/lib/couchbase/key_value_scan.rb +2 -0
  1118. data/lib/couchbase/logger.rb +2 -0
  1119. data/lib/couchbase/management/analytics_index_manager.rb +2 -0
  1120. data/lib/couchbase/management/bucket_manager.rb +2 -0
  1121. data/lib/couchbase/management/collection_manager.rb +2 -0
  1122. data/lib/couchbase/management/collection_query_index_manager.rb +2 -0
  1123. data/lib/couchbase/management/query_index_manager.rb +2 -0
  1124. data/lib/couchbase/management/scope_search_index_manager.rb +2 -0
  1125. data/lib/couchbase/management/search_index_manager.rb +2 -0
  1126. data/lib/couchbase/management/user_manager.rb +2 -0
  1127. data/lib/couchbase/management/view_index_manager.rb +2 -0
  1128. data/lib/couchbase/management.rb +2 -0
  1129. data/lib/couchbase/mutation_state.rb +2 -0
  1130. data/lib/couchbase/options.rb +2 -0
  1131. data/lib/couchbase/protostellar/request_generator/kv.rb +1 -1
  1132. data/lib/couchbase/query_options.rb +2 -0
  1133. data/lib/couchbase/railtie.rb +2 -0
  1134. data/lib/couchbase/raw_binary_transcoder.rb +2 -0
  1135. data/lib/couchbase/raw_json_transcoder.rb +2 -0
  1136. data/lib/couchbase/raw_string_transcoder.rb +2 -0
  1137. data/lib/couchbase/scope.rb +2 -0
  1138. data/lib/couchbase/search_options.rb +91 -63
  1139. data/lib/couchbase/subdoc.rb +5 -3
  1140. data/lib/couchbase/transcoder_flags.rb +2 -0
  1141. data/lib/couchbase/utils/generic_logger_adapter.rb +3 -1
  1142. data/lib/couchbase/utils/stdlib_logger_adapter.rb +2 -0
  1143. data/lib/couchbase/utils/time.rb +3 -1
  1144. data/lib/couchbase/utils.rb +2 -0
  1145. data/lib/couchbase/version.rb +3 -1
  1146. data/lib/couchbase/view_options.rb +2 -0
  1147. data/lib/couchbase.rb +2 -0
  1148. data/lib/rails/generators/couchbase/config/config_generator.rb +2 -0
  1149. metadata +83 -26
  1150. data/ext/couchbase/core/impl/internal_manager_error_context.cxx +0 -113
  1151. data/ext/couchbase/core/impl/internal_manager_error_context.hxx +0 -60
  1152. data/ext/couchbase/core/impl/manager_error_context.cxx +0 -100
  1153. data/ext/couchbase/core/impl/search_error_context.cxx +0 -147
  1154. data/ext/couchbase/couchbase/analytics_error_context.hxx +0 -143
  1155. data/ext/couchbase/couchbase/fmt/key_value_error_map_attribute.hxx +0 -100
  1156. data/ext/couchbase/couchbase/fmt/key_value_status_code.hxx +0 -269
  1157. data/ext/couchbase/couchbase/key_value_error_context.hxx +0 -229
  1158. data/ext/couchbase/couchbase/key_value_error_map_attribute.hxx +0 -136
  1159. data/ext/couchbase/couchbase/key_value_error_map_info.hxx +0 -138
  1160. data/ext/couchbase/couchbase/key_value_extended_error_info.hxx +0 -86
  1161. data/ext/couchbase/couchbase/key_value_status_code.hxx +0 -109
  1162. data/ext/couchbase/couchbase/manager_error_context.hxx +0 -111
  1163. data/ext/couchbase/couchbase/query_error_context.hxx +0 -145
  1164. data/ext/couchbase/couchbase/search_error_context.hxx +0 -138
  1165. data/ext/couchbase/couchbase/subdocument_error_context.hxx +0 -147
  1166. data/ext/couchbase/couchbase/transaction_op_error_context.hxx +0 -76
@@ -80,7 +80,8 @@ struct is_trivially_copy_constructible<std::vector<T, A>> : std::false_type {
80
80
  } // namespace tl
81
81
  #endif
82
82
 
83
- #define TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) tl::detail::is_trivially_copy_constructible<T>
83
+ #define TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \
84
+ tl::detail::is_trivially_copy_constructible<T>
84
85
  #define TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(T) std::is_trivially_copy_assignable<T>
85
86
  #define TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible<T>
86
87
  #else
@@ -117,7 +118,7 @@ class monostate
117
118
  };
118
119
 
119
120
  struct in_place_t {
120
- explicit in_place_t() = default;
121
+ explicit in_place_t() = default;
121
122
  };
122
123
  static constexpr in_place_t in_place{};
123
124
  #endif
@@ -125,87 +126,87 @@ static constexpr in_place_t in_place{};
125
126
  template<class E>
126
127
  class unexpected
127
128
  {
128
- public:
129
- static_assert(!std::is_same<E, void>::value, "E must not be void");
130
-
131
- unexpected() = delete;
132
- constexpr explicit unexpected(const E& e)
133
- : m_val(e)
134
- {
135
- }
136
-
137
- constexpr explicit unexpected(E&& e)
138
- : m_val(std::move(e))
139
- {
140
- }
141
-
142
- constexpr const E& value() const&
143
- {
144
- return m_val;
145
- }
146
- TL_EXPECTED_11_CONSTEXPR E& value() &
147
- {
148
- return m_val;
149
- }
150
- TL_EXPECTED_11_CONSTEXPR E&& value() &&
151
- {
152
- return std::move(m_val);
153
- }
154
- constexpr const E&& value() const&&
155
- {
156
- return std::move(m_val);
157
- }
158
-
159
- private:
160
- E m_val;
129
+ public:
130
+ static_assert(!std::is_same<E, void>::value, "E must not be void");
131
+
132
+ unexpected() = delete;
133
+ constexpr explicit unexpected(const E& e)
134
+ : m_val(e)
135
+ {
136
+ }
137
+
138
+ constexpr explicit unexpected(E&& e)
139
+ : m_val(std::move(e))
140
+ {
141
+ }
142
+
143
+ constexpr const E& value() const&
144
+ {
145
+ return m_val;
146
+ }
147
+ TL_EXPECTED_11_CONSTEXPR E& value() &
148
+ {
149
+ return m_val;
150
+ }
151
+ TL_EXPECTED_11_CONSTEXPR E&& value() &&
152
+ {
153
+ return std::move(m_val);
154
+ }
155
+ constexpr const E&& value() const&&
156
+ {
157
+ return std::move(m_val);
158
+ }
159
+
160
+ private:
161
+ E m_val;
161
162
  };
162
163
 
163
164
  template<class E>
164
165
  constexpr bool
165
166
  operator==(const unexpected<E>& lhs, const unexpected<E>& rhs)
166
167
  {
167
- return lhs.value() == rhs.value();
168
+ return lhs.value() == rhs.value();
168
169
  }
169
170
  template<class E>
170
171
  constexpr bool
171
172
  operator!=(const unexpected<E>& lhs, const unexpected<E>& rhs)
172
173
  {
173
- return lhs.value() != rhs.value();
174
+ return lhs.value() != rhs.value();
174
175
  }
175
176
  template<class E>
176
177
  constexpr bool
177
178
  operator<(const unexpected<E>& lhs, const unexpected<E>& rhs)
178
179
  {
179
- return lhs.value() < rhs.value();
180
+ return lhs.value() < rhs.value();
180
181
  }
181
182
  template<class E>
182
183
  constexpr bool
183
184
  operator<=(const unexpected<E>& lhs, const unexpected<E>& rhs)
184
185
  {
185
- return lhs.value() <= rhs.value();
186
+ return lhs.value() <= rhs.value();
186
187
  }
187
188
  template<class E>
188
189
  constexpr bool
189
190
  operator>(const unexpected<E>& lhs, const unexpected<E>& rhs)
190
191
  {
191
- return lhs.value() > rhs.value();
192
+ return lhs.value() > rhs.value();
192
193
  }
193
194
  template<class E>
194
195
  constexpr bool
195
196
  operator>=(const unexpected<E>& lhs, const unexpected<E>& rhs)
196
197
  {
197
- return lhs.value() >= rhs.value();
198
+ return lhs.value() >= rhs.value();
198
199
  }
199
200
 
200
201
  template<class E>
201
202
  unexpected<typename std::decay<E>::type>
202
203
  make_unexpected(E&& e)
203
204
  {
204
- return unexpected<typename std::decay<E>::type>(std::forward<E>(e));
205
+ return unexpected<typename std::decay<E>::type>(std::forward<E>(e));
205
206
  }
206
207
 
207
208
  struct unexpect_t {
208
- unexpect_t() = default;
209
+ unexpect_t() = default;
209
210
  };
210
211
  static constexpr unexpect_t unexpect{};
211
212
 
@@ -216,12 +217,12 @@ template<typename E>
216
217
  throw_exception(E&& e)
217
218
  {
218
219
  #ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
219
- throw std::forward<E>(e);
220
+ throw std::forward<E>(e);
220
221
  #else
221
222
  #ifdef _MSC_VER
222
- __assume(0);
223
+ __assume(0);
223
224
  #else
224
- __builtin_unreachable();
225
+ __builtin_unreachable();
225
226
  #endif
226
227
  #endif
227
228
  }
@@ -297,7 +298,8 @@ struct is_const_or_const_ref<T const> : std::true_type {
297
298
  template<typename Fn,
298
299
  typename... Args,
299
300
  #ifdef TL_TRAITS_LIBCXX_MEM_FN_WORKAROUND
300
- typename = enable_if_t<!(is_pointer_to_non_const_member_func<Fn>::value && is_const_or_const_ref<Args...>::value)>,
301
+ typename = enable_if_t<!(is_pointer_to_non_const_member_func<Fn>::value &&
302
+ is_const_or_const_ref<Args...>::value)>,
301
303
  #endif
302
304
  typename = enable_if_t<std::is_member_pointer<decay_t<Fn>>::value>,
303
305
  int = 0>
@@ -305,15 +307,17 @@ constexpr auto
305
307
  invoke(Fn&& f, Args&&... args) noexcept(noexcept(std::mem_fn(f)(std::forward<Args>(args)...)))
306
308
  -> decltype(std::mem_fn(f)(std::forward<Args>(args)...))
307
309
  {
308
- return std::mem_fn(f)(std::forward<Args>(args)...);
310
+ return std::mem_fn(f)(std::forward<Args>(args)...);
309
311
  }
310
312
 
311
- template<typename Fn, typename... Args, typename = enable_if_t<!std::is_member_pointer<decay_t<Fn>>::value>>
313
+ template<typename Fn,
314
+ typename... Args,
315
+ typename = enable_if_t<!std::is_member_pointer<decay_t<Fn>>::value>>
312
316
  constexpr auto
313
317
  invoke(Fn&& f, Args&&... args) noexcept(noexcept(std::forward<Fn>(f)(std::forward<Args>(args)...)))
314
318
  -> decltype(std::forward<Fn>(f)(std::forward<Args>(args)...))
315
319
  {
316
- return std::forward<Fn>(f)(std::forward<Args>(args)...);
320
+ return std::forward<Fn>(f)(std::forward<Args>(args)...);
317
321
  }
318
322
 
319
323
  // std::invoke_result from C++17
@@ -321,8 +325,11 @@ template<class F, class, class... Us>
321
325
  struct invoke_result_impl;
322
326
 
323
327
  template<class F, class... Us>
324
- struct invoke_result_impl<F, decltype(detail::invoke(std::declval<F>(), std::declval<Us>()...), void()), Us...> {
325
- using type = decltype(detail::invoke(std::declval<F>(), std::declval<Us>()...));
328
+ struct invoke_result_impl<F,
329
+ decltype(detail::invoke(std::declval<F>(), std::declval<Us>()...),
330
+ void()),
331
+ Us...> {
332
+ using type = decltype(detail::invoke(std::declval<F>(), std::declval<Us>()...));
326
333
  };
327
334
 
328
335
  template<class F, class... Us>
@@ -373,7 +380,9 @@ uses_std(int);
373
380
 
374
381
  template<class T>
375
382
  struct is_std_swap_noexcept
376
- : std::integral_constant<bool, std::is_nothrow_move_constructible<T>::value && std::is_nothrow_move_assignable<T>::value> {
383
+ : std::integral_constant<bool,
384
+ std::is_nothrow_move_constructible<T>::value &&
385
+ std::is_nothrow_move_assignable<T>::value> {
377
386
  };
378
387
 
379
388
  template<class T, std::size_t N>
@@ -390,23 +399,26 @@ struct is_swappable
390
399
  : std::integral_constant<bool,
391
400
  decltype(detail::swap_adl_tests::can_swap<T, U>(0))::value &&
392
401
  (!decltype(detail::swap_adl_tests::uses_std<T, U>(0))::value ||
393
- (std::is_move_assignable<T>::value && std::is_move_constructible<T>::value))> {
402
+ (std::is_move_assignable<T>::value &&
403
+ std::is_move_constructible<T>::value))> {
394
404
  };
395
405
 
396
406
  template<class T, std::size_t N>
397
407
  struct is_swappable<T[N], T[N]>
398
408
  : std::integral_constant<bool,
399
409
  decltype(detail::swap_adl_tests::can_swap<T[N], T[N]>(0))::value &&
400
- (!decltype(detail::swap_adl_tests::uses_std<T[N], T[N]>(0))::value || is_swappable<T, T>::value)> {
410
+ (!decltype(detail::swap_adl_tests::uses_std<T[N], T[N]>(0))::value ||
411
+ is_swappable<T, T>::value)> {
401
412
  };
402
413
 
403
414
  template<class T, class U = T>
404
415
  struct is_nothrow_swappable
405
- : std::integral_constant<
406
- bool,
407
- is_swappable<T, U>::value &&
408
- ((decltype(detail::swap_adl_tests::uses_std<T, U>(0))::value&& detail::swap_adl_tests::is_std_swap_noexcept<T>::value) ||
409
- (!decltype(detail::swap_adl_tests::uses_std<T, U>(0))::value&& detail::swap_adl_tests::is_adl_swap_noexcept<T, U>::value))> {
416
+ : std::integral_constant<bool,
417
+ is_swappable<T, U>::value &&
418
+ ((decltype(detail::swap_adl_tests::uses_std<T, U>(0))::value &&
419
+ detail::swap_adl_tests::is_std_swap_noexcept<T>::value) ||
420
+ (!decltype(detail::swap_adl_tests::uses_std<T, U>(0))::value &&
421
+ detail::swap_adl_tests::is_adl_swap_noexcept<T, U>::value))> {
410
422
  };
411
423
  #endif
412
424
  #endif
@@ -423,16 +435,22 @@ using is_expected = is_expected_impl<decay_t<T>>;
423
435
 
424
436
  template<class T, class E, class U>
425
437
  using expected_enable_forward_value =
426
- detail::enable_if_t<std::is_constructible<T, U&&>::value && !std::is_same<detail::decay_t<U>, in_place_t>::value &&
427
- !std::is_same<expected<T, E>, detail::decay_t<U>>::value && !std::is_same<unexpected<E>, detail::decay_t<U>>::value>;
438
+ detail::enable_if_t<std::is_constructible<T, U&&>::value &&
439
+ !std::is_same<detail::decay_t<U>, in_place_t>::value &&
440
+ !std::is_same<expected<T, E>, detail::decay_t<U>>::value &&
441
+ !std::is_same<unexpected<E>, detail::decay_t<U>>::value>;
428
442
 
429
443
  template<class T, class E, class U, class G, class UR, class GR>
430
444
  using expected_enable_from_other =
431
445
  detail::enable_if_t<std::is_constructible<T, UR>::value && std::is_constructible<E, GR>::value &&
432
- !std::is_constructible<T, expected<U, G>&>::value && !std::is_constructible<T, expected<U, G>&&>::value &&
433
- !std::is_constructible<T, const expected<U, G>&>::value && !std::is_constructible<T, const expected<U, G>&&>::value &&
434
- !std::is_convertible<expected<U, G>&, T>::value && !std::is_convertible<expected<U, G>&&, T>::value &&
435
- !std::is_convertible<const expected<U, G>&, T>::value && !std::is_convertible<const expected<U, G>&&, T>::value>;
446
+ !std::is_constructible<T, expected<U, G>&>::value &&
447
+ !std::is_constructible<T, expected<U, G>&&>::value &&
448
+ !std::is_constructible<T, const expected<U, G>&>::value &&
449
+ !std::is_constructible<T, const expected<U, G>&&>::value &&
450
+ !std::is_convertible<expected<U, G>&, T>::value &&
451
+ !std::is_convertible<expected<U, G>&&, T>::value &&
452
+ !std::is_convertible<const expected<U, G>&, T>::value &&
453
+ !std::is_convertible<const expected<U, G>&&, T>::value>;
436
454
 
437
455
  template<class T, class U>
438
456
  using is_void_or = conditional_t<std::is_void<T>::value, std::true_type, U>;
@@ -463,631 +481,679 @@ static constexpr no_init_t no_init{};
463
481
  // This specialization is for where neither `T` or `E` is trivially
464
482
  // destructible, so the destructors must be called on destruction of the
465
483
  // `expected`
466
- template<class T, class E, bool = std::is_trivially_destructible<T>::value, bool = std::is_trivially_destructible<E>::value>
484
+ template<class T,
485
+ class E,
486
+ bool = std::is_trivially_destructible<T>::value,
487
+ bool = std::is_trivially_destructible<E>::value>
467
488
  struct expected_storage_base {
468
- constexpr expected_storage_base()
469
- : m_val(T{})
470
- , m_has_val(true)
471
- {
472
- }
473
- constexpr expected_storage_base(no_init_t)
474
- : m_no_init()
475
- , m_has_val(false)
476
- {
477
- }
478
-
479
- template<class... Args, detail::enable_if_t<std::is_constructible<T, Args&&...>::value>* = nullptr>
480
- constexpr expected_storage_base(in_place_t, Args&&... args)
481
- : m_val(std::forward<Args>(args)...)
482
- , m_has_val(true)
483
- {
484
- }
485
-
486
- template<class U, class... Args, detail::enable_if_t<std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
487
- constexpr expected_storage_base(in_place_t, std::initializer_list<U> il, Args&&... args)
488
- : m_val(il, std::forward<Args>(args)...)
489
- , m_has_val(true)
490
- {
491
- }
492
- template<class... Args, detail::enable_if_t<std::is_constructible<E, Args&&...>::value>* = nullptr>
493
- constexpr explicit expected_storage_base(unexpect_t, Args&&... args)
494
- : m_unexpect(std::forward<Args>(args)...)
495
- , m_has_val(false)
496
- {
497
- }
498
-
499
- template<class U, class... Args, detail::enable_if_t<std::is_constructible<E, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
500
- constexpr explicit expected_storage_base(unexpect_t, std::initializer_list<U> il, Args&&... args)
501
- : m_unexpect(il, std::forward<Args>(args)...)
502
- , m_has_val(false)
503
- {
504
- }
505
-
506
- ~expected_storage_base()
507
- {
508
- if (m_has_val) {
509
- m_val.~T();
510
- } else {
511
- m_unexpect.~unexpected<E>();
512
- }
513
- }
514
- union {
515
- T m_val;
516
- unexpected<E> m_unexpect;
517
- char m_no_init;
518
- };
519
- bool m_has_val;
489
+ constexpr expected_storage_base()
490
+ : m_val(T{})
491
+ , m_has_val(true)
492
+ {
493
+ }
494
+ constexpr expected_storage_base(no_init_t)
495
+ : m_no_init()
496
+ , m_has_val(false)
497
+ {
498
+ }
499
+
500
+ template<class... Args,
501
+ detail::enable_if_t<std::is_constructible<T, Args&&...>::value>* = nullptr>
502
+ constexpr expected_storage_base(in_place_t, Args&&... args)
503
+ : m_val(std::forward<Args>(args)...)
504
+ , m_has_val(true)
505
+ {
506
+ }
507
+
508
+ template<class U,
509
+ class... Args,
510
+ detail::enable_if_t<
511
+ std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
512
+ constexpr expected_storage_base(in_place_t, std::initializer_list<U> il, Args&&... args)
513
+ : m_val(il, std::forward<Args>(args)...)
514
+ , m_has_val(true)
515
+ {
516
+ }
517
+ template<class... Args,
518
+ detail::enable_if_t<std::is_constructible<E, Args&&...>::value>* = nullptr>
519
+ constexpr explicit expected_storage_base(unexpect_t, Args&&... args)
520
+ : m_unexpect(std::forward<Args>(args)...)
521
+ , m_has_val(false)
522
+ {
523
+ }
524
+
525
+ template<class U,
526
+ class... Args,
527
+ detail::enable_if_t<
528
+ std::is_constructible<E, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
529
+ constexpr explicit expected_storage_base(unexpect_t, std::initializer_list<U> il, Args&&... args)
530
+ : m_unexpect(il, std::forward<Args>(args)...)
531
+ , m_has_val(false)
532
+ {
533
+ }
534
+
535
+ ~expected_storage_base()
536
+ {
537
+ if (m_has_val) {
538
+ m_val.~T();
539
+ } else {
540
+ m_unexpect.~unexpected<E>();
541
+ }
542
+ }
543
+ union {
544
+ T m_val;
545
+ unexpected<E> m_unexpect;
546
+ char m_no_init;
547
+ };
548
+ bool m_has_val;
520
549
  };
521
550
 
522
551
  // This specialization is for when both `T` and `E` are trivially-destructible,
523
552
  // so the destructor of the `expected` can be trivial.
524
553
  template<class T, class E>
525
554
  struct expected_storage_base<T, E, true, true> {
526
- constexpr expected_storage_base()
527
- : m_val(T{})
528
- , m_has_val(true)
529
- {
530
- }
531
- constexpr expected_storage_base(no_init_t)
532
- : m_no_init()
533
- , m_has_val(false)
534
- {
535
- }
536
-
537
- template<class... Args, detail::enable_if_t<std::is_constructible<T, Args&&...>::value>* = nullptr>
538
- constexpr expected_storage_base(in_place_t, Args&&... args)
539
- : m_val(std::forward<Args>(args)...)
540
- , m_has_val(true)
541
- {
542
- }
543
-
544
- template<class U, class... Args, detail::enable_if_t<std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
545
- constexpr expected_storage_base(in_place_t, std::initializer_list<U> il, Args&&... args)
546
- : m_val(il, std::forward<Args>(args)...)
547
- , m_has_val(true)
548
- {
549
- }
550
- template<class... Args, detail::enable_if_t<std::is_constructible<E, Args&&...>::value>* = nullptr>
551
- constexpr explicit expected_storage_base(unexpect_t, Args&&... args)
552
- : m_unexpect(std::forward<Args>(args)...)
553
- , m_has_val(false)
554
- {
555
- }
556
-
557
- template<class U, class... Args, detail::enable_if_t<std::is_constructible<E, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
558
- constexpr explicit expected_storage_base(unexpect_t, std::initializer_list<U> il, Args&&... args)
559
- : m_unexpect(il, std::forward<Args>(args)...)
560
- , m_has_val(false)
561
- {
562
- }
563
-
564
- ~expected_storage_base() = default;
565
- union {
566
- T m_val;
567
- unexpected<E> m_unexpect;
568
- char m_no_init;
569
- };
570
- bool m_has_val;
555
+ constexpr expected_storage_base()
556
+ : m_val(T{})
557
+ , m_has_val(true)
558
+ {
559
+ }
560
+ constexpr expected_storage_base(no_init_t)
561
+ : m_no_init()
562
+ , m_has_val(false)
563
+ {
564
+ }
565
+
566
+ template<class... Args,
567
+ detail::enable_if_t<std::is_constructible<T, Args&&...>::value>* = nullptr>
568
+ constexpr expected_storage_base(in_place_t, Args&&... args)
569
+ : m_val(std::forward<Args>(args)...)
570
+ , m_has_val(true)
571
+ {
572
+ }
573
+
574
+ template<class U,
575
+ class... Args,
576
+ detail::enable_if_t<
577
+ std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
578
+ constexpr expected_storage_base(in_place_t, std::initializer_list<U> il, Args&&... args)
579
+ : m_val(il, std::forward<Args>(args)...)
580
+ , m_has_val(true)
581
+ {
582
+ }
583
+ template<class... Args,
584
+ detail::enable_if_t<std::is_constructible<E, Args&&...>::value>* = nullptr>
585
+ constexpr explicit expected_storage_base(unexpect_t, Args&&... args)
586
+ : m_unexpect(std::forward<Args>(args)...)
587
+ , m_has_val(false)
588
+ {
589
+ }
590
+
591
+ template<class U,
592
+ class... Args,
593
+ detail::enable_if_t<
594
+ std::is_constructible<E, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
595
+ constexpr explicit expected_storage_base(unexpect_t, std::initializer_list<U> il, Args&&... args)
596
+ : m_unexpect(il, std::forward<Args>(args)...)
597
+ , m_has_val(false)
598
+ {
599
+ }
600
+
601
+ ~expected_storage_base() = default;
602
+ union {
603
+ T m_val;
604
+ unexpected<E> m_unexpect;
605
+ char m_no_init;
606
+ };
607
+ bool m_has_val;
571
608
  };
572
609
 
573
610
  // T is trivial, E is not.
574
611
  template<class T, class E>
575
612
  struct expected_storage_base<T, E, true, false> {
576
- constexpr expected_storage_base()
577
- : m_val(T{})
578
- , m_has_val(true)
579
- {
580
- }
581
- TL_EXPECTED_MSVC2015_CONSTEXPR expected_storage_base(no_init_t)
582
- : m_no_init()
583
- , m_has_val(false)
584
- {
585
- }
586
-
587
- template<class... Args, detail::enable_if_t<std::is_constructible<T, Args&&...>::value>* = nullptr>
588
- constexpr expected_storage_base(in_place_t, Args&&... args)
589
- : m_val(std::forward<Args>(args)...)
590
- , m_has_val(true)
591
- {
592
- }
593
-
594
- template<class U, class... Args, detail::enable_if_t<std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
595
- constexpr expected_storage_base(in_place_t, std::initializer_list<U> il, Args&&... args)
596
- : m_val(il, std::forward<Args>(args)...)
597
- , m_has_val(true)
598
- {
599
- }
600
- template<class... Args, detail::enable_if_t<std::is_constructible<E, Args&&...>::value>* = nullptr>
601
- constexpr explicit expected_storage_base(unexpect_t, Args&&... args)
602
- : m_unexpect(std::forward<Args>(args)...)
603
- , m_has_val(false)
604
- {
605
- }
606
-
607
- template<class U, class... Args, detail::enable_if_t<std::is_constructible<E, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
608
- constexpr explicit expected_storage_base(unexpect_t, std::initializer_list<U> il, Args&&... args)
609
- : m_unexpect(il, std::forward<Args>(args)...)
610
- , m_has_val(false)
611
- {
612
- }
613
-
614
- ~expected_storage_base()
615
- {
616
- if (!m_has_val) {
617
- m_unexpect.~unexpected<E>();
618
- }
619
- }
620
-
621
- union {
622
- T m_val;
623
- unexpected<E> m_unexpect;
624
- char m_no_init;
625
- };
626
- bool m_has_val;
613
+ constexpr expected_storage_base()
614
+ : m_val(T{})
615
+ , m_has_val(true)
616
+ {
617
+ }
618
+ TL_EXPECTED_MSVC2015_CONSTEXPR expected_storage_base(no_init_t)
619
+ : m_no_init()
620
+ , m_has_val(false)
621
+ {
622
+ }
623
+
624
+ template<class... Args,
625
+ detail::enable_if_t<std::is_constructible<T, Args&&...>::value>* = nullptr>
626
+ constexpr expected_storage_base(in_place_t, Args&&... args)
627
+ : m_val(std::forward<Args>(args)...)
628
+ , m_has_val(true)
629
+ {
630
+ }
631
+
632
+ template<class U,
633
+ class... Args,
634
+ detail::enable_if_t<
635
+ std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
636
+ constexpr expected_storage_base(in_place_t, std::initializer_list<U> il, Args&&... args)
637
+ : m_val(il, std::forward<Args>(args)...)
638
+ , m_has_val(true)
639
+ {
640
+ }
641
+ template<class... Args,
642
+ detail::enable_if_t<std::is_constructible<E, Args&&...>::value>* = nullptr>
643
+ constexpr explicit expected_storage_base(unexpect_t, Args&&... args)
644
+ : m_unexpect(std::forward<Args>(args)...)
645
+ , m_has_val(false)
646
+ {
647
+ }
648
+
649
+ template<class U,
650
+ class... Args,
651
+ detail::enable_if_t<
652
+ std::is_constructible<E, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
653
+ constexpr explicit expected_storage_base(unexpect_t, std::initializer_list<U> il, Args&&... args)
654
+ : m_unexpect(il, std::forward<Args>(args)...)
655
+ , m_has_val(false)
656
+ {
657
+ }
658
+
659
+ ~expected_storage_base()
660
+ {
661
+ if (!m_has_val) {
662
+ m_unexpect.~unexpected<E>();
663
+ }
664
+ }
665
+
666
+ union {
667
+ T m_val;
668
+ unexpected<E> m_unexpect;
669
+ char m_no_init;
670
+ };
671
+ bool m_has_val;
627
672
  };
628
673
 
629
674
  // E is trivial, T is not.
630
675
  template<class T, class E>
631
676
  struct expected_storage_base<T, E, false, true> {
632
- constexpr expected_storage_base()
633
- : m_val(T{})
634
- , m_has_val(true)
635
- {
636
- }
637
- constexpr expected_storage_base(no_init_t)
638
- : m_no_init()
639
- , m_has_val(false)
640
- {
641
- }
642
-
643
- template<class... Args, detail::enable_if_t<std::is_constructible<T, Args&&...>::value>* = nullptr>
644
- constexpr expected_storage_base(in_place_t, Args&&... args)
645
- : m_val(std::forward<Args>(args)...)
646
- , m_has_val(true)
647
- {
648
- }
649
-
650
- template<class U, class... Args, detail::enable_if_t<std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
651
- constexpr expected_storage_base(in_place_t, std::initializer_list<U> il, Args&&... args)
652
- : m_val(il, std::forward<Args>(args)...)
653
- , m_has_val(true)
654
- {
655
- }
656
- template<class... Args, detail::enable_if_t<std::is_constructible<E, Args&&...>::value>* = nullptr>
657
- constexpr explicit expected_storage_base(unexpect_t, Args&&... args)
658
- : m_unexpect(std::forward<Args>(args)...)
659
- , m_has_val(false)
660
- {
661
- }
662
-
663
- template<class U, class... Args, detail::enable_if_t<std::is_constructible<E, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
664
- constexpr explicit expected_storage_base(unexpect_t, std::initializer_list<U> il, Args&&... args)
665
- : m_unexpect(il, std::forward<Args>(args)...)
666
- , m_has_val(false)
667
- {
668
- }
669
-
670
- ~expected_storage_base()
671
- {
672
- if (m_has_val) {
673
- m_val.~T();
674
- }
675
- }
676
- union {
677
- T m_val;
678
- unexpected<E> m_unexpect;
679
- char m_no_init;
680
- };
681
- bool m_has_val;
677
+ constexpr expected_storage_base()
678
+ : m_val(T{})
679
+ , m_has_val(true)
680
+ {
681
+ }
682
+ constexpr expected_storage_base(no_init_t)
683
+ : m_no_init()
684
+ , m_has_val(false)
685
+ {
686
+ }
687
+
688
+ template<class... Args,
689
+ detail::enable_if_t<std::is_constructible<T, Args&&...>::value>* = nullptr>
690
+ constexpr expected_storage_base(in_place_t, Args&&... args)
691
+ : m_val(std::forward<Args>(args)...)
692
+ , m_has_val(true)
693
+ {
694
+ }
695
+
696
+ template<class U,
697
+ class... Args,
698
+ detail::enable_if_t<
699
+ std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
700
+ constexpr expected_storage_base(in_place_t, std::initializer_list<U> il, Args&&... args)
701
+ : m_val(il, std::forward<Args>(args)...)
702
+ , m_has_val(true)
703
+ {
704
+ }
705
+ template<class... Args,
706
+ detail::enable_if_t<std::is_constructible<E, Args&&...>::value>* = nullptr>
707
+ constexpr explicit expected_storage_base(unexpect_t, Args&&... args)
708
+ : m_unexpect(std::forward<Args>(args)...)
709
+ , m_has_val(false)
710
+ {
711
+ }
712
+
713
+ template<class U,
714
+ class... Args,
715
+ detail::enable_if_t<
716
+ std::is_constructible<E, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
717
+ constexpr explicit expected_storage_base(unexpect_t, std::initializer_list<U> il, Args&&... args)
718
+ : m_unexpect(il, std::forward<Args>(args)...)
719
+ , m_has_val(false)
720
+ {
721
+ }
722
+
723
+ ~expected_storage_base()
724
+ {
725
+ if (m_has_val) {
726
+ m_val.~T();
727
+ }
728
+ }
729
+ union {
730
+ T m_val;
731
+ unexpected<E> m_unexpect;
732
+ char m_no_init;
733
+ };
734
+ bool m_has_val;
682
735
  };
683
736
 
684
737
  // `T` is `void`, `E` is trivially-destructible
685
738
  template<class E>
686
739
  struct expected_storage_base<void, E, false, true> {
687
- TL_EXPECTED_MSVC2015_CONSTEXPR expected_storage_base()
688
- : m_has_val(true)
689
- {
690
- }
691
- constexpr expected_storage_base(no_init_t)
692
- : m_val()
693
- , m_has_val(false)
694
- {
695
- }
696
-
697
- constexpr expected_storage_base(in_place_t)
698
- : m_has_val(true)
699
- {
700
- }
701
-
702
- template<class... Args, detail::enable_if_t<std::is_constructible<E, Args&&...>::value>* = nullptr>
703
- constexpr explicit expected_storage_base(unexpect_t, Args&&... args)
704
- : m_unexpect(std::forward<Args>(args)...)
705
- , m_has_val(false)
706
- {
707
- }
708
-
709
- template<class U, class... Args, detail::enable_if_t<std::is_constructible<E, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
710
- constexpr explicit expected_storage_base(unexpect_t, std::initializer_list<U> il, Args&&... args)
711
- : m_unexpect(il, std::forward<Args>(args)...)
712
- , m_has_val(false)
713
- {
714
- }
715
-
716
- ~expected_storage_base() = default;
717
- struct dummy {
718
- };
719
- union {
720
- unexpected<E> m_unexpect;
721
- dummy m_val;
722
- };
723
- bool m_has_val;
740
+ TL_EXPECTED_MSVC2015_CONSTEXPR expected_storage_base()
741
+ : m_has_val(true)
742
+ {
743
+ }
744
+ constexpr expected_storage_base(no_init_t)
745
+ : m_val()
746
+ , m_has_val(false)
747
+ {
748
+ }
749
+
750
+ constexpr expected_storage_base(in_place_t)
751
+ : m_has_val(true)
752
+ {
753
+ }
754
+
755
+ template<class... Args,
756
+ detail::enable_if_t<std::is_constructible<E, Args&&...>::value>* = nullptr>
757
+ constexpr explicit expected_storage_base(unexpect_t, Args&&... args)
758
+ : m_unexpect(std::forward<Args>(args)...)
759
+ , m_has_val(false)
760
+ {
761
+ }
762
+
763
+ template<class U,
764
+ class... Args,
765
+ detail::enable_if_t<
766
+ std::is_constructible<E, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
767
+ constexpr explicit expected_storage_base(unexpect_t, std::initializer_list<U> il, Args&&... args)
768
+ : m_unexpect(il, std::forward<Args>(args)...)
769
+ , m_has_val(false)
770
+ {
771
+ }
772
+
773
+ ~expected_storage_base() = default;
774
+ struct dummy {
775
+ };
776
+ union {
777
+ unexpected<E> m_unexpect;
778
+ dummy m_val;
779
+ };
780
+ bool m_has_val;
724
781
  };
725
782
 
726
783
  // `T` is `void`, `E` is not trivially-destructible
727
784
  template<class E>
728
785
  struct expected_storage_base<void, E, false, false> {
729
- constexpr expected_storage_base()
730
- : m_dummy()
731
- , m_has_val(true)
732
- {
733
- }
734
- constexpr expected_storage_base(no_init_t)
735
- : m_dummy()
736
- , m_has_val(false)
737
- {
738
- }
739
-
740
- constexpr expected_storage_base(in_place_t)
741
- : m_dummy()
742
- , m_has_val(true)
743
- {
744
- }
745
-
746
- template<class... Args, detail::enable_if_t<std::is_constructible<E, Args&&...>::value>* = nullptr>
747
- constexpr explicit expected_storage_base(unexpect_t, Args&&... args)
748
- : m_unexpect(std::forward<Args>(args)...)
749
- , m_has_val(false)
750
- {
751
- }
752
-
753
- template<class U, class... Args, detail::enable_if_t<std::is_constructible<E, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
754
- constexpr explicit expected_storage_base(unexpect_t, std::initializer_list<U> il, Args&&... args)
755
- : m_unexpect(il, std::forward<Args>(args)...)
756
- , m_has_val(false)
757
- {
758
- }
759
-
760
- ~expected_storage_base()
761
- {
762
- if (!m_has_val) {
763
- m_unexpect.~unexpected<E>();
764
- }
765
- }
766
-
767
- union {
768
- unexpected<E> m_unexpect;
769
- char m_dummy;
770
- };
771
- bool m_has_val;
786
+ constexpr expected_storage_base()
787
+ : m_dummy()
788
+ , m_has_val(true)
789
+ {
790
+ }
791
+ constexpr expected_storage_base(no_init_t)
792
+ : m_dummy()
793
+ , m_has_val(false)
794
+ {
795
+ }
796
+
797
+ constexpr expected_storage_base(in_place_t)
798
+ : m_dummy()
799
+ , m_has_val(true)
800
+ {
801
+ }
802
+
803
+ template<class... Args,
804
+ detail::enable_if_t<std::is_constructible<E, Args&&...>::value>* = nullptr>
805
+ constexpr explicit expected_storage_base(unexpect_t, Args&&... args)
806
+ : m_unexpect(std::forward<Args>(args)...)
807
+ , m_has_val(false)
808
+ {
809
+ }
810
+
811
+ template<class U,
812
+ class... Args,
813
+ detail::enable_if_t<
814
+ std::is_constructible<E, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
815
+ constexpr explicit expected_storage_base(unexpect_t, std::initializer_list<U> il, Args&&... args)
816
+ : m_unexpect(il, std::forward<Args>(args)...)
817
+ , m_has_val(false)
818
+ {
819
+ }
820
+
821
+ ~expected_storage_base()
822
+ {
823
+ if (!m_has_val) {
824
+ m_unexpect.~unexpected<E>();
825
+ }
826
+ }
827
+
828
+ union {
829
+ unexpected<E> m_unexpect;
830
+ char m_dummy;
831
+ };
832
+ bool m_has_val;
772
833
  };
773
834
 
774
835
  // This base class provides some handy member functions which can be used in
775
836
  // further derived classes
776
837
  template<class T, class E>
777
838
  struct expected_operations_base : expected_storage_base<T, E> {
778
- using expected_storage_base<T, E>::expected_storage_base;
779
-
780
- template<class... Args>
781
- void construct(Args&&... args) noexcept
782
- {
783
- new (std::addressof(this->m_val)) T(std::forward<Args>(args)...);
784
- this->m_has_val = true;
785
- }
786
-
787
- template<class Rhs>
788
- void construct_with(Rhs&& rhs) noexcept
789
- {
790
- new (std::addressof(this->m_val)) T(std::forward<Rhs>(rhs).get());
791
- this->m_has_val = true;
792
- }
793
-
794
- template<class... Args>
795
- void construct_error(Args&&... args) noexcept
796
- {
797
- new (std::addressof(this->m_unexpect)) unexpected<E>(std::forward<Args>(args)...);
798
- this->m_has_val = false;
799
- }
839
+ using expected_storage_base<T, E>::expected_storage_base;
840
+
841
+ template<class... Args>
842
+ void construct(Args&&... args) noexcept
843
+ {
844
+ new (std::addressof(this->m_val)) T(std::forward<Args>(args)...);
845
+ this->m_has_val = true;
846
+ }
847
+
848
+ template<class Rhs>
849
+ void construct_with(Rhs&& rhs) noexcept
850
+ {
851
+ new (std::addressof(this->m_val)) T(std::forward<Rhs>(rhs).get());
852
+ this->m_has_val = true;
853
+ }
854
+
855
+ template<class... Args>
856
+ void construct_error(Args&&... args) noexcept
857
+ {
858
+ new (std::addressof(this->m_unexpect)) unexpected<E>(std::forward<Args>(args)...);
859
+ this->m_has_val = false;
860
+ }
800
861
 
801
862
  #ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
802
863
 
803
- // These assign overloads ensure that the most efficient assignment
804
- // implementation is used while maintaining the strong exception guarantee.
805
- // The problematic case is where rhs has a value, but *this does not.
806
- //
807
- // This overload handles the case where we can just copy-construct `T`
808
- // directly into place without throwing.
809
- template<class U = T, detail::enable_if_t<std::is_nothrow_copy_constructible<U>::value>* = nullptr>
810
- void assign(const expected_operations_base& rhs) noexcept
811
- {
812
- if (!this->m_has_val && rhs.m_has_val) {
813
- geterr().~unexpected<E>();
814
- construct(rhs.get());
815
- } else {
816
- assign_common(rhs);
817
- }
818
- }
819
-
820
- // This overload handles the case where we can attempt to create a copy of
821
- // `T`, then no-throw move it into place if the copy was successful.
822
- template<class U = T,
823
- detail::enable_if_t<!std::is_nothrow_copy_constructible<U>::value && std::is_nothrow_move_constructible<U>::value>* = nullptr>
824
- void assign(const expected_operations_base& rhs) noexcept
825
- {
826
- if (!this->m_has_val && rhs.m_has_val) {
827
- T tmp = rhs.get();
828
- geterr().~unexpected<E>();
829
- construct(std::move(tmp));
830
- } else {
831
- assign_common(rhs);
832
- }
833
- }
834
-
835
- // This overload is the worst-case, where we have to move-construct the
836
- // unexpected value into temporary storage, then try to copy the T into place.
837
- // If the construction succeeds, then everything is fine, but if it throws,
838
- // then we move the old unexpected value back into place before rethrowing the
839
- // exception.
840
- template<class U = T,
841
- detail::enable_if_t<!std::is_nothrow_copy_constructible<U>::value && !std::is_nothrow_move_constructible<U>::value>* = nullptr>
842
- void assign(const expected_operations_base& rhs)
843
- {
844
- if (!this->m_has_val && rhs.m_has_val) {
845
- auto tmp = std::move(geterr());
846
- geterr().~unexpected<E>();
864
+ // These assign overloads ensure that the most efficient assignment
865
+ // implementation is used while maintaining the strong exception guarantee.
866
+ // The problematic case is where rhs has a value, but *this does not.
867
+ //
868
+ // This overload handles the case where we can just copy-construct `T`
869
+ // directly into place without throwing.
870
+ template<class U = T,
871
+ detail::enable_if_t<std::is_nothrow_copy_constructible<U>::value>* = nullptr>
872
+ void assign(const expected_operations_base& rhs) noexcept
873
+ {
874
+ if (!this->m_has_val && rhs.m_has_val) {
875
+ geterr().~unexpected<E>();
876
+ construct(rhs.get());
877
+ } else {
878
+ assign_common(rhs);
879
+ }
880
+ }
881
+
882
+ // This overload handles the case where we can attempt to create a copy of
883
+ // `T`, then no-throw move it into place if the copy was successful.
884
+ template<class U = T,
885
+ detail::enable_if_t<!std::is_nothrow_copy_constructible<U>::value &&
886
+ std::is_nothrow_move_constructible<U>::value>* = nullptr>
887
+ void assign(const expected_operations_base& rhs) noexcept
888
+ {
889
+ if (!this->m_has_val && rhs.m_has_val) {
890
+ T tmp = rhs.get();
891
+ geterr().~unexpected<E>();
892
+ construct(std::move(tmp));
893
+ } else {
894
+ assign_common(rhs);
895
+ }
896
+ }
897
+
898
+ // This overload is the worst-case, where we have to move-construct the
899
+ // unexpected value into temporary storage, then try to copy the T into place.
900
+ // If the construction succeeds, then everything is fine, but if it throws,
901
+ // then we move the old unexpected value back into place before rethrowing the
902
+ // exception.
903
+ template<class U = T,
904
+ detail::enable_if_t<!std::is_nothrow_copy_constructible<U>::value &&
905
+ !std::is_nothrow_move_constructible<U>::value>* = nullptr>
906
+ void assign(const expected_operations_base& rhs)
907
+ {
908
+ if (!this->m_has_val && rhs.m_has_val) {
909
+ auto tmp = std::move(geterr());
910
+ geterr().~unexpected<E>();
847
911
 
848
912
  #ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
849
- try {
850
- construct(rhs.get());
851
- } catch (...) {
852
- geterr() = std::move(tmp);
853
- throw;
854
- }
913
+ try {
914
+ construct(rhs.get());
915
+ } catch (...) {
916
+ geterr() = std::move(tmp);
917
+ throw;
918
+ }
855
919
  #else
856
- construct(rhs.get());
920
+ construct(rhs.get());
857
921
  #endif
858
- } else {
859
- assign_common(rhs);
860
- }
861
- }
862
-
863
- // These overloads do the same as above, but for rvalues
864
- template<class U = T, detail::enable_if_t<std::is_nothrow_move_constructible<U>::value>* = nullptr>
865
- void assign(expected_operations_base&& rhs) noexcept
866
- {
867
- if (!this->m_has_val && rhs.m_has_val) {
868
- geterr().~unexpected<E>();
869
- construct(std::move(rhs).get());
870
- } else {
871
- assign_common(std::move(rhs));
872
- }
873
- }
874
-
875
- template<class U = T, detail::enable_if_t<!std::is_nothrow_move_constructible<U>::value>* = nullptr>
876
- void assign(expected_operations_base&& rhs)
877
- {
878
- if (!this->m_has_val && rhs.m_has_val) {
879
- auto tmp = std::move(geterr());
880
- geterr().~unexpected<E>();
922
+ } else {
923
+ assign_common(rhs);
924
+ }
925
+ }
926
+
927
+ // These overloads do the same as above, but for rvalues
928
+ template<class U = T,
929
+ detail::enable_if_t<std::is_nothrow_move_constructible<U>::value>* = nullptr>
930
+ void assign(expected_operations_base&& rhs) noexcept
931
+ {
932
+ if (!this->m_has_val && rhs.m_has_val) {
933
+ geterr().~unexpected<E>();
934
+ construct(std::move(rhs).get());
935
+ } else {
936
+ assign_common(std::move(rhs));
937
+ }
938
+ }
939
+
940
+ template<class U = T,
941
+ detail::enable_if_t<!std::is_nothrow_move_constructible<U>::value>* = nullptr>
942
+ void assign(expected_operations_base&& rhs)
943
+ {
944
+ if (!this->m_has_val && rhs.m_has_val) {
945
+ auto tmp = std::move(geterr());
946
+ geterr().~unexpected<E>();
881
947
  #ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
882
- try {
883
- construct(std::move(rhs).get());
884
- } catch (...) {
885
- geterr() = std::move(tmp);
886
- throw;
887
- }
948
+ try {
949
+ construct(std::move(rhs).get());
950
+ } catch (...) {
951
+ geterr() = std::move(tmp);
952
+ throw;
953
+ }
888
954
  #else
889
- construct(std::move(rhs).get());
955
+ construct(std::move(rhs).get());
890
956
  #endif
891
- } else {
892
- assign_common(std::move(rhs));
893
- }
957
+ } else {
958
+ assign_common(std::move(rhs));
894
959
  }
960
+ }
895
961
 
896
962
  #else
897
963
 
898
- // If exceptions are disabled then we can just copy-construct
899
- void assign(const expected_operations_base& rhs) noexcept
900
- {
901
- if (!this->m_has_val && rhs.m_has_val) {
902
- geterr().~unexpected<E>();
903
- construct(rhs.get());
904
- } else {
905
- assign_common(rhs);
906
- }
964
+ // If exceptions are disabled then we can just copy-construct
965
+ void assign(const expected_operations_base& rhs) noexcept
966
+ {
967
+ if (!this->m_has_val && rhs.m_has_val) {
968
+ geterr().~unexpected<E>();
969
+ construct(rhs.get());
970
+ } else {
971
+ assign_common(rhs);
907
972
  }
973
+ }
908
974
 
909
- void assign(expected_operations_base&& rhs) noexcept
910
- {
911
- if (!this->m_has_val && rhs.m_has_val) {
912
- geterr().~unexpected<E>();
913
- construct(std::move(rhs).get());
914
- } else {
915
- assign_common(rhs);
916
- }
975
+ void assign(expected_operations_base&& rhs) noexcept
976
+ {
977
+ if (!this->m_has_val && rhs.m_has_val) {
978
+ geterr().~unexpected<E>();
979
+ construct(std::move(rhs).get());
980
+ } else {
981
+ assign_common(rhs);
917
982
  }
983
+ }
918
984
 
919
985
  #endif
920
986
 
921
- // The common part of move/copy assigning
922
- template<class Rhs>
923
- void assign_common(Rhs&& rhs)
924
- {
925
- if (this->m_has_val) {
926
- if (rhs.m_has_val) {
927
- get() = std::forward<Rhs>(rhs).get();
928
- } else {
929
- destroy_val();
930
- construct_error(std::forward<Rhs>(rhs).geterr());
931
- }
932
- } else {
933
- if (!rhs.m_has_val) {
934
- geterr() = std::forward<Rhs>(rhs).geterr();
935
- }
936
- }
937
- }
938
-
939
- bool has_value() const
940
- {
941
- return this->m_has_val;
942
- }
943
-
944
- TL_EXPECTED_11_CONSTEXPR T& get() &
945
- {
946
- return this->m_val;
947
- }
948
- constexpr const T& get() const&
949
- {
950
- return this->m_val;
951
- }
952
- TL_EXPECTED_11_CONSTEXPR T&& get() &&
953
- {
954
- return std::move(this->m_val);
955
- }
987
+ // The common part of move/copy assigning
988
+ template<class Rhs>
989
+ void assign_common(Rhs&& rhs)
990
+ {
991
+ if (this->m_has_val) {
992
+ if (rhs.m_has_val) {
993
+ get() = std::forward<Rhs>(rhs).get();
994
+ } else {
995
+ destroy_val();
996
+ construct_error(std::forward<Rhs>(rhs).geterr());
997
+ }
998
+ } else {
999
+ if (!rhs.m_has_val) {
1000
+ geterr() = std::forward<Rhs>(rhs).geterr();
1001
+ }
1002
+ }
1003
+ }
1004
+
1005
+ bool has_value() const
1006
+ {
1007
+ return this->m_has_val;
1008
+ }
1009
+
1010
+ TL_EXPECTED_11_CONSTEXPR T& get() &
1011
+ {
1012
+ return this->m_val;
1013
+ }
1014
+ constexpr const T& get() const&
1015
+ {
1016
+ return this->m_val;
1017
+ }
1018
+ TL_EXPECTED_11_CONSTEXPR T&& get() &&
1019
+ {
1020
+ return std::move(this->m_val);
1021
+ }
956
1022
  #ifndef TL_EXPECTED_NO_CONSTRR
957
- constexpr const T&& get() const&&
958
- {
959
- return std::move(this->m_val);
960
- }
1023
+ constexpr const T&& get() const&&
1024
+ {
1025
+ return std::move(this->m_val);
1026
+ }
961
1027
  #endif
962
1028
 
963
- TL_EXPECTED_11_CONSTEXPR unexpected<E>& geterr() &
964
- {
965
- return this->m_unexpect;
966
- }
967
- constexpr const unexpected<E>& geterr() const&
968
- {
969
- return this->m_unexpect;
970
- }
971
- TL_EXPECTED_11_CONSTEXPR unexpected<E>&& geterr() &&
972
- {
973
- return std::move(this->m_unexpect);
974
- }
1029
+ TL_EXPECTED_11_CONSTEXPR unexpected<E>& geterr() &
1030
+ {
1031
+ return this->m_unexpect;
1032
+ }
1033
+ constexpr const unexpected<E>& geterr() const&
1034
+ {
1035
+ return this->m_unexpect;
1036
+ }
1037
+ TL_EXPECTED_11_CONSTEXPR unexpected<E>&& geterr() &&
1038
+ {
1039
+ return std::move(this->m_unexpect);
1040
+ }
975
1041
  #ifndef TL_EXPECTED_NO_CONSTRR
976
- constexpr const unexpected<E>&& geterr() const&&
977
- {
978
- return std::move(this->m_unexpect);
979
- }
1042
+ constexpr const unexpected<E>&& geterr() const&&
1043
+ {
1044
+ return std::move(this->m_unexpect);
1045
+ }
980
1046
  #endif
981
1047
 
982
- TL_EXPECTED_11_CONSTEXPR void destroy_val()
983
- {
984
- get().~T();
985
- }
1048
+ TL_EXPECTED_11_CONSTEXPR void destroy_val()
1049
+ {
1050
+ get().~T();
1051
+ }
986
1052
  };
987
1053
 
988
1054
  // This base class provides some handy member functions which can be used in
989
1055
  // further derived classes
990
1056
  template<class E>
991
1057
  struct expected_operations_base<void, E> : expected_storage_base<void, E> {
992
- using expected_storage_base<void, E>::expected_storage_base;
993
-
994
- template<class... Args>
995
- void construct() noexcept
996
- {
997
- this->m_has_val = true;
998
- }
999
-
1000
- // This function doesn't use its argument, but needs it so that code in
1001
- // levels above this can work independently of whether T is void
1002
- template<class Rhs>
1003
- void construct_with(Rhs&&) noexcept
1004
- {
1005
- this->m_has_val = true;
1006
- }
1007
-
1008
- template<class... Args>
1009
- void construct_error(Args&&... args) noexcept
1010
- {
1011
- new (std::addressof(this->m_unexpect)) unexpected<E>(std::forward<Args>(args)...);
1012
- this->m_has_val = false;
1013
- }
1014
-
1015
- template<class Rhs>
1016
- void assign(Rhs&& rhs) noexcept
1017
- {
1018
- if (!this->m_has_val) {
1019
- if (rhs.m_has_val) {
1020
- geterr().~unexpected<E>();
1021
- construct();
1022
- } else {
1023
- geterr() = std::forward<Rhs>(rhs).geterr();
1024
- }
1025
- } else {
1026
- if (!rhs.m_has_val) {
1027
- construct_error(std::forward<Rhs>(rhs).geterr());
1028
- }
1029
- }
1030
- }
1031
-
1032
- bool has_value() const
1033
- {
1034
- return this->m_has_val;
1035
- }
1036
-
1037
- TL_EXPECTED_11_CONSTEXPR unexpected<E>& geterr() &
1038
- {
1039
- return this->m_unexpect;
1040
- }
1041
- constexpr const unexpected<E>& geterr() const&
1042
- {
1043
- return this->m_unexpect;
1044
- }
1045
- TL_EXPECTED_11_CONSTEXPR unexpected<E>&& geterr() &&
1046
- {
1047
- return std::move(this->m_unexpect);
1048
- }
1058
+ using expected_storage_base<void, E>::expected_storage_base;
1059
+
1060
+ template<class... Args>
1061
+ void construct() noexcept
1062
+ {
1063
+ this->m_has_val = true;
1064
+ }
1065
+
1066
+ // This function doesn't use its argument, but needs it so that code in
1067
+ // levels above this can work independently of whether T is void
1068
+ template<class Rhs>
1069
+ void construct_with(Rhs&&) noexcept
1070
+ {
1071
+ this->m_has_val = true;
1072
+ }
1073
+
1074
+ template<class... Args>
1075
+ void construct_error(Args&&... args) noexcept
1076
+ {
1077
+ new (std::addressof(this->m_unexpect)) unexpected<E>(std::forward<Args>(args)...);
1078
+ this->m_has_val = false;
1079
+ }
1080
+
1081
+ template<class Rhs>
1082
+ void assign(Rhs&& rhs) noexcept
1083
+ {
1084
+ if (!this->m_has_val) {
1085
+ if (rhs.m_has_val) {
1086
+ geterr().~unexpected<E>();
1087
+ construct();
1088
+ } else {
1089
+ geterr() = std::forward<Rhs>(rhs).geterr();
1090
+ }
1091
+ } else {
1092
+ if (!rhs.m_has_val) {
1093
+ construct_error(std::forward<Rhs>(rhs).geterr());
1094
+ }
1095
+ }
1096
+ }
1097
+
1098
+ bool has_value() const
1099
+ {
1100
+ return this->m_has_val;
1101
+ }
1102
+
1103
+ TL_EXPECTED_11_CONSTEXPR unexpected<E>& geterr() &
1104
+ {
1105
+ return this->m_unexpect;
1106
+ }
1107
+ constexpr const unexpected<E>& geterr() const&
1108
+ {
1109
+ return this->m_unexpect;
1110
+ }
1111
+ TL_EXPECTED_11_CONSTEXPR unexpected<E>&& geterr() &&
1112
+ {
1113
+ return std::move(this->m_unexpect);
1114
+ }
1049
1115
  #ifndef TL_EXPECTED_NO_CONSTRR
1050
- constexpr const unexpected<E>&& geterr() const&&
1051
- {
1052
- return std::move(this->m_unexpect);
1053
- }
1116
+ constexpr const unexpected<E>&& geterr() const&&
1117
+ {
1118
+ return std::move(this->m_unexpect);
1119
+ }
1054
1120
  #endif
1055
1121
 
1056
- TL_EXPECTED_11_CONSTEXPR void destroy_val()
1057
- {
1058
- // no-op
1059
- }
1122
+ TL_EXPECTED_11_CONSTEXPR void destroy_val()
1123
+ {
1124
+ // no-op
1125
+ }
1060
1126
  };
1061
1127
 
1062
1128
  // This class manages conditionally having a trivial copy constructor
1063
1129
  // This specialization is for when T and E are trivially copy constructible
1064
1130
  template<class T,
1065
1131
  class E,
1066
- bool =
1067
- is_void_or<T, TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)>::value&& TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value>
1132
+ bool = is_void_or<T, TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)>::value &&
1133
+ TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value>
1068
1134
  struct expected_copy_base : expected_operations_base<T, E> {
1069
- using expected_operations_base<T, E>::expected_operations_base;
1135
+ using expected_operations_base<T, E>::expected_operations_base;
1070
1136
  };
1071
1137
 
1072
1138
  // This specialization is for when T or E are not trivially copy constructible
1073
1139
  template<class T, class E>
1074
1140
  struct expected_copy_base<T, E, false> : expected_operations_base<T, E> {
1075
- using expected_operations_base<T, E>::expected_operations_base;
1076
-
1077
- expected_copy_base() = default;
1078
- expected_copy_base(const expected_copy_base& rhs)
1079
- : expected_operations_base<T, E>(no_init)
1080
- {
1081
- if (rhs.has_value()) {
1082
- this->construct_with(rhs);
1083
- } else {
1084
- this->construct_error(rhs.geterr());
1085
- }
1086
- }
1087
-
1088
- expected_copy_base(expected_copy_base&& rhs) = default;
1089
- expected_copy_base& operator=(const expected_copy_base& rhs) = default;
1090
- expected_copy_base& operator=(expected_copy_base&& rhs) = default;
1141
+ using expected_operations_base<T, E>::expected_operations_base;
1142
+
1143
+ expected_copy_base() = default;
1144
+ expected_copy_base(const expected_copy_base& rhs)
1145
+ : expected_operations_base<T, E>(no_init)
1146
+ {
1147
+ if (rhs.has_value()) {
1148
+ this->construct_with(rhs);
1149
+ } else {
1150
+ this->construct_error(rhs.geterr());
1151
+ }
1152
+ }
1153
+
1154
+ expected_copy_base(expected_copy_base&& rhs) = default;
1155
+ expected_copy_base& operator=(const expected_copy_base& rhs) = default;
1156
+ expected_copy_base& operator=(expected_copy_base&& rhs) = default;
1091
1157
  };
1092
1158
 
1093
1159
  // This class manages conditionally having a trivial move constructor
@@ -1098,9 +1164,10 @@ struct expected_copy_base<T, E, false> : expected_operations_base<T, E> {
1098
1164
  #ifndef TL_EXPECTED_GCC49
1099
1165
  template<class T,
1100
1166
  class E,
1101
- bool = is_void_or<T, std::is_trivially_move_constructible<T>>::value&& std::is_trivially_move_constructible<E>::value>
1167
+ bool = is_void_or<T, std::is_trivially_move_constructible<T>>::value &&
1168
+ std::is_trivially_move_constructible<E>::value>
1102
1169
  struct expected_move_base : expected_copy_base<T, E> {
1103
- using expected_copy_base<T, E>::expected_copy_base;
1170
+ using expected_copy_base<T, E>::expected_copy_base;
1104
1171
  };
1105
1172
  #else
1106
1173
  template<class T, class E, bool = false>
@@ -1108,51 +1175,53 @@ struct expected_move_base;
1108
1175
  #endif
1109
1176
  template<class T, class E>
1110
1177
  struct expected_move_base<T, E, false> : expected_copy_base<T, E> {
1111
- using expected_copy_base<T, E>::expected_copy_base;
1112
-
1113
- expected_move_base() = default;
1114
- expected_move_base(const expected_move_base& rhs) = default;
1115
-
1116
- expected_move_base(expected_move_base&& rhs) noexcept(std::is_nothrow_move_constructible<T>::value)
1117
- : expected_copy_base<T, E>(no_init)
1118
- {
1119
- if (rhs.has_value()) {
1120
- this->construct_with(std::move(rhs));
1121
- } else {
1122
- this->construct_error(std::move(rhs.geterr()));
1123
- }
1124
- }
1125
- expected_move_base& operator=(const expected_move_base& rhs) = default;
1126
- expected_move_base& operator=(expected_move_base&& rhs) = default;
1178
+ using expected_copy_base<T, E>::expected_copy_base;
1179
+
1180
+ expected_move_base() = default;
1181
+ expected_move_base(const expected_move_base& rhs) = default;
1182
+
1183
+ expected_move_base(expected_move_base&& rhs) noexcept(
1184
+ std::is_nothrow_move_constructible<T>::value)
1185
+ : expected_copy_base<T, E>(no_init)
1186
+ {
1187
+ if (rhs.has_value()) {
1188
+ this->construct_with(std::move(rhs));
1189
+ } else {
1190
+ this->construct_error(std::move(rhs.geterr()));
1191
+ }
1192
+ }
1193
+ expected_move_base& operator=(const expected_move_base& rhs) = default;
1194
+ expected_move_base& operator=(expected_move_base&& rhs) = default;
1127
1195
  };
1128
1196
 
1129
1197
  // This class manages conditionally having a trivial copy assignment operator
1130
1198
  template<class T,
1131
1199
  class E,
1132
- bool =
1133
- is_void_or<T,
1134
- conjunction<TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(T),
1135
- TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T),
1136
- TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T)>>::value&& TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(E)::value&&
1137
- TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value&& TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(E)::value>
1200
+ bool = is_void_or<T,
1201
+ conjunction<TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(T),
1202
+ TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T),
1203
+ TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T)>>::value &&
1204
+ TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(E)::value &&
1205
+ TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value &&
1206
+ TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(E)::value>
1138
1207
  struct expected_copy_assign_base : expected_move_base<T, E> {
1139
- using expected_move_base<T, E>::expected_move_base;
1208
+ using expected_move_base<T, E>::expected_move_base;
1140
1209
  };
1141
1210
 
1142
1211
  template<class T, class E>
1143
1212
  struct expected_copy_assign_base<T, E, false> : expected_move_base<T, E> {
1144
- using expected_move_base<T, E>::expected_move_base;
1145
-
1146
- expected_copy_assign_base() = default;
1147
- expected_copy_assign_base(const expected_copy_assign_base& rhs) = default;
1148
-
1149
- expected_copy_assign_base(expected_copy_assign_base&& rhs) = default;
1150
- expected_copy_assign_base& operator=(const expected_copy_assign_base& rhs)
1151
- {
1152
- this->assign(rhs);
1153
- return *this;
1154
- }
1155
- expected_copy_assign_base& operator=(expected_copy_assign_base&& rhs) = default;
1213
+ using expected_move_base<T, E>::expected_move_base;
1214
+
1215
+ expected_copy_assign_base() = default;
1216
+ expected_copy_assign_base(const expected_copy_assign_base& rhs) = default;
1217
+
1218
+ expected_copy_assign_base(expected_copy_assign_base&& rhs) = default;
1219
+ expected_copy_assign_base& operator=(const expected_copy_assign_base& rhs)
1220
+ {
1221
+ this->assign(rhs);
1222
+ return *this;
1223
+ }
1224
+ expected_copy_assign_base& operator=(expected_copy_assign_base&& rhs) = default;
1156
1225
  };
1157
1226
 
1158
1227
  // This class manages conditionally having a trivial move assignment operator
@@ -1161,15 +1230,17 @@ struct expected_copy_assign_base<T, E, false> : expected_move_base<T, E> {
1161
1230
  // to make do with a non-trivial move assignment operator even if T is trivially
1162
1231
  // move assignable
1163
1232
  #ifndef TL_EXPECTED_GCC49
1164
- template<
1165
- class T,
1166
- class E,
1167
- bool = is_void_or<
1168
- T,
1169
- conjunction<std::is_trivially_destructible<T>, std::is_trivially_move_constructible<T>, std::is_trivially_move_assignable<T>>>::value&&
1170
- std::is_trivially_destructible<E>::value&& std::is_trivially_move_constructible<E>::value&& std::is_trivially_move_assignable<E>::value>
1233
+ template<class T,
1234
+ class E,
1235
+ bool = is_void_or<T,
1236
+ conjunction<std::is_trivially_destructible<T>,
1237
+ std::is_trivially_move_constructible<T>,
1238
+ std::is_trivially_move_assignable<T>>>::value &&
1239
+ std::is_trivially_destructible<E>::value &&
1240
+ std::is_trivially_move_constructible<E>::value &&
1241
+ std::is_trivially_move_assignable<E>::value>
1171
1242
  struct expected_move_assign_base : expected_copy_assign_base<T, E> {
1172
- using expected_copy_assign_base<T, E>::expected_copy_assign_base;
1243
+ using expected_copy_assign_base<T, E>::expected_copy_assign_base;
1173
1244
  };
1174
1245
  #else
1175
1246
  template<class T, class E, bool = false>
@@ -1178,62 +1249,64 @@ struct expected_move_assign_base;
1178
1249
 
1179
1250
  template<class T, class E>
1180
1251
  struct expected_move_assign_base<T, E, false> : expected_copy_assign_base<T, E> {
1181
- using expected_copy_assign_base<T, E>::expected_copy_assign_base;
1252
+ using expected_copy_assign_base<T, E>::expected_copy_assign_base;
1182
1253
 
1183
- expected_move_assign_base() = default;
1184
- expected_move_assign_base(const expected_move_assign_base& rhs) = default;
1254
+ expected_move_assign_base() = default;
1255
+ expected_move_assign_base(const expected_move_assign_base& rhs) = default;
1185
1256
 
1186
- expected_move_assign_base(expected_move_assign_base&& rhs) = default;
1257
+ expected_move_assign_base(expected_move_assign_base&& rhs) = default;
1187
1258
 
1188
- expected_move_assign_base& operator=(const expected_move_assign_base& rhs) = default;
1259
+ expected_move_assign_base& operator=(const expected_move_assign_base& rhs) = default;
1189
1260
 
1190
- expected_move_assign_base& operator=(expected_move_assign_base&& rhs) noexcept(
1191
- std::is_nothrow_move_constructible<T>::value&& std::is_nothrow_move_assignable<T>::value)
1192
- {
1193
- this->assign(std::move(rhs));
1194
- return *this;
1195
- }
1261
+ expected_move_assign_base& operator=(expected_move_assign_base&& rhs) noexcept(
1262
+ std::is_nothrow_move_constructible<T>::value && std::is_nothrow_move_assignable<T>::value)
1263
+ {
1264
+ this->assign(std::move(rhs));
1265
+ return *this;
1266
+ }
1196
1267
  };
1197
1268
 
1198
1269
  // expected_delete_ctor_base will conditionally delete copy and move
1199
1270
  // constructors depending on whether T is copy/move constructible
1200
1271
  template<class T,
1201
1272
  class E,
1202
- bool EnableCopy = (is_copy_constructible_or_void<T>::value && std::is_copy_constructible<E>::value),
1203
- bool EnableMove = (is_move_constructible_or_void<T>::value && std::is_move_constructible<E>::value)>
1273
+ bool EnableCopy =
1274
+ (is_copy_constructible_or_void<T>::value && std::is_copy_constructible<E>::value),
1275
+ bool EnableMove =
1276
+ (is_move_constructible_or_void<T>::value && std::is_move_constructible<E>::value)>
1204
1277
  struct expected_delete_ctor_base {
1205
- expected_delete_ctor_base() = default;
1206
- expected_delete_ctor_base(const expected_delete_ctor_base&) = default;
1207
- expected_delete_ctor_base(expected_delete_ctor_base&&) noexcept = default;
1208
- expected_delete_ctor_base& operator=(const expected_delete_ctor_base&) = default;
1209
- expected_delete_ctor_base& operator=(expected_delete_ctor_base&&) noexcept = default;
1278
+ expected_delete_ctor_base() = default;
1279
+ expected_delete_ctor_base(const expected_delete_ctor_base&) = default;
1280
+ expected_delete_ctor_base(expected_delete_ctor_base&&) noexcept = default;
1281
+ expected_delete_ctor_base& operator=(const expected_delete_ctor_base&) = default;
1282
+ expected_delete_ctor_base& operator=(expected_delete_ctor_base&&) noexcept = default;
1210
1283
  };
1211
1284
 
1212
1285
  template<class T, class E>
1213
1286
  struct expected_delete_ctor_base<T, E, true, false> {
1214
- expected_delete_ctor_base() = default;
1215
- expected_delete_ctor_base(const expected_delete_ctor_base&) = default;
1216
- expected_delete_ctor_base(expected_delete_ctor_base&&) noexcept = delete;
1217
- expected_delete_ctor_base& operator=(const expected_delete_ctor_base&) = default;
1218
- expected_delete_ctor_base& operator=(expected_delete_ctor_base&&) noexcept = default;
1287
+ expected_delete_ctor_base() = default;
1288
+ expected_delete_ctor_base(const expected_delete_ctor_base&) = default;
1289
+ expected_delete_ctor_base(expected_delete_ctor_base&&) noexcept = delete;
1290
+ expected_delete_ctor_base& operator=(const expected_delete_ctor_base&) = default;
1291
+ expected_delete_ctor_base& operator=(expected_delete_ctor_base&&) noexcept = default;
1219
1292
  };
1220
1293
 
1221
1294
  template<class T, class E>
1222
1295
  struct expected_delete_ctor_base<T, E, false, true> {
1223
- expected_delete_ctor_base() = default;
1224
- expected_delete_ctor_base(const expected_delete_ctor_base&) = delete;
1225
- expected_delete_ctor_base(expected_delete_ctor_base&&) noexcept = default;
1226
- expected_delete_ctor_base& operator=(const expected_delete_ctor_base&) = default;
1227
- expected_delete_ctor_base& operator=(expected_delete_ctor_base&&) noexcept = default;
1296
+ expected_delete_ctor_base() = default;
1297
+ expected_delete_ctor_base(const expected_delete_ctor_base&) = delete;
1298
+ expected_delete_ctor_base(expected_delete_ctor_base&&) noexcept = default;
1299
+ expected_delete_ctor_base& operator=(const expected_delete_ctor_base&) = default;
1300
+ expected_delete_ctor_base& operator=(expected_delete_ctor_base&&) noexcept = default;
1228
1301
  };
1229
1302
 
1230
1303
  template<class T, class E>
1231
1304
  struct expected_delete_ctor_base<T, E, false, false> {
1232
- expected_delete_ctor_base() = default;
1233
- expected_delete_ctor_base(const expected_delete_ctor_base&) = delete;
1234
- expected_delete_ctor_base(expected_delete_ctor_base&&) noexcept = delete;
1235
- expected_delete_ctor_base& operator=(const expected_delete_ctor_base&) = default;
1236
- expected_delete_ctor_base& operator=(expected_delete_ctor_base&&) noexcept = default;
1305
+ expected_delete_ctor_base() = default;
1306
+ expected_delete_ctor_base(const expected_delete_ctor_base&) = delete;
1307
+ expected_delete_ctor_base(expected_delete_ctor_base&&) noexcept = delete;
1308
+ expected_delete_ctor_base& operator=(const expected_delete_ctor_base&) = default;
1309
+ expected_delete_ctor_base& operator=(expected_delete_ctor_base&&) noexcept = default;
1237
1310
  };
1238
1311
 
1239
1312
  // expected_delete_assign_base will conditionally delete copy and move
@@ -1241,115 +1314,119 @@ struct expected_delete_ctor_base<T, E, false, false> {
1241
1314
  // assignable
1242
1315
  template<class T,
1243
1316
  class E,
1244
- bool EnableCopy = (is_copy_constructible_or_void<T>::value && std::is_copy_constructible<E>::value &&
1245
- is_copy_assignable_or_void<T>::value && std::is_copy_assignable<E>::value),
1246
- bool EnableMove = (is_move_constructible_or_void<T>::value && std::is_move_constructible<E>::value &&
1247
- is_move_assignable_or_void<T>::value && std::is_move_assignable<E>::value)>
1317
+ bool EnableCopy =
1318
+ (is_copy_constructible_or_void<T>::value && std::is_copy_constructible<E>::value &&
1319
+ is_copy_assignable_or_void<T>::value && std::is_copy_assignable<E>::value),
1320
+ bool EnableMove =
1321
+ (is_move_constructible_or_void<T>::value && std::is_move_constructible<E>::value &&
1322
+ is_move_assignable_or_void<T>::value && std::is_move_assignable<E>::value)>
1248
1323
  struct expected_delete_assign_base {
1249
- expected_delete_assign_base() = default;
1250
- expected_delete_assign_base(const expected_delete_assign_base&) = default;
1251
- expected_delete_assign_base(expected_delete_assign_base&&) noexcept = default;
1252
- expected_delete_assign_base& operator=(const expected_delete_assign_base&) = default;
1253
- expected_delete_assign_base& operator=(expected_delete_assign_base&&) noexcept = default;
1324
+ expected_delete_assign_base() = default;
1325
+ expected_delete_assign_base(const expected_delete_assign_base&) = default;
1326
+ expected_delete_assign_base(expected_delete_assign_base&&) noexcept = default;
1327
+ expected_delete_assign_base& operator=(const expected_delete_assign_base&) = default;
1328
+ expected_delete_assign_base& operator=(expected_delete_assign_base&&) noexcept = default;
1254
1329
  };
1255
1330
 
1256
1331
  template<class T, class E>
1257
1332
  struct expected_delete_assign_base<T, E, true, false> {
1258
- expected_delete_assign_base() = default;
1259
- expected_delete_assign_base(const expected_delete_assign_base&) = default;
1260
- expected_delete_assign_base(expected_delete_assign_base&&) noexcept = default;
1261
- expected_delete_assign_base& operator=(const expected_delete_assign_base&) = default;
1262
- expected_delete_assign_base& operator=(expected_delete_assign_base&&) noexcept = delete;
1333
+ expected_delete_assign_base() = default;
1334
+ expected_delete_assign_base(const expected_delete_assign_base&) = default;
1335
+ expected_delete_assign_base(expected_delete_assign_base&&) noexcept = default;
1336
+ expected_delete_assign_base& operator=(const expected_delete_assign_base&) = default;
1337
+ expected_delete_assign_base& operator=(expected_delete_assign_base&&) noexcept = delete;
1263
1338
  };
1264
1339
 
1265
1340
  template<class T, class E>
1266
1341
  struct expected_delete_assign_base<T, E, false, true> {
1267
- expected_delete_assign_base() = default;
1268
- expected_delete_assign_base(const expected_delete_assign_base&) = default;
1269
- expected_delete_assign_base(expected_delete_assign_base&&) noexcept = default;
1270
- expected_delete_assign_base& operator=(const expected_delete_assign_base&) = delete;
1271
- expected_delete_assign_base& operator=(expected_delete_assign_base&&) noexcept = default;
1342
+ expected_delete_assign_base() = default;
1343
+ expected_delete_assign_base(const expected_delete_assign_base&) = default;
1344
+ expected_delete_assign_base(expected_delete_assign_base&&) noexcept = default;
1345
+ expected_delete_assign_base& operator=(const expected_delete_assign_base&) = delete;
1346
+ expected_delete_assign_base& operator=(expected_delete_assign_base&&) noexcept = default;
1272
1347
  };
1273
1348
 
1274
1349
  template<class T, class E>
1275
1350
  struct expected_delete_assign_base<T, E, false, false> {
1276
- expected_delete_assign_base() = default;
1277
- expected_delete_assign_base(const expected_delete_assign_base&) = default;
1278
- expected_delete_assign_base(expected_delete_assign_base&&) noexcept = default;
1279
- expected_delete_assign_base& operator=(const expected_delete_assign_base&) = delete;
1280
- expected_delete_assign_base& operator=(expected_delete_assign_base&&) noexcept = delete;
1351
+ expected_delete_assign_base() = default;
1352
+ expected_delete_assign_base(const expected_delete_assign_base&) = default;
1353
+ expected_delete_assign_base(expected_delete_assign_base&&) noexcept = default;
1354
+ expected_delete_assign_base& operator=(const expected_delete_assign_base&) = delete;
1355
+ expected_delete_assign_base& operator=(expected_delete_assign_base&&) noexcept = delete;
1281
1356
  };
1282
1357
 
1283
1358
  // This is needed to be able to construct the expected_default_ctor_base which
1284
1359
  // follows, while still conditionally deleting the default constructor.
1285
1360
  struct default_constructor_tag {
1286
- explicit constexpr default_constructor_tag() = default;
1361
+ explicit constexpr default_constructor_tag() = default;
1287
1362
  };
1288
1363
 
1289
1364
  // expected_default_ctor_base will ensure that expected has a deleted default
1290
1365
  // consturctor if T is not default constructible.
1291
1366
  // This specialization is for when T is default constructible
1292
- template<class T, class E, bool Enable = std::is_default_constructible<T>::value || std::is_void<T>::value>
1367
+ template<class T,
1368
+ class E,
1369
+ bool Enable = std::is_default_constructible<T>::value || std::is_void<T>::value>
1293
1370
  struct expected_default_ctor_base {
1294
- constexpr expected_default_ctor_base() noexcept = default;
1295
- constexpr expected_default_ctor_base(expected_default_ctor_base const&) noexcept = default;
1296
- constexpr expected_default_ctor_base(expected_default_ctor_base&&) noexcept = default;
1297
- expected_default_ctor_base& operator=(expected_default_ctor_base const&) noexcept = default;
1298
- expected_default_ctor_base& operator=(expected_default_ctor_base&&) noexcept = default;
1299
-
1300
- constexpr explicit expected_default_ctor_base(default_constructor_tag)
1301
- {
1302
- }
1371
+ constexpr expected_default_ctor_base() noexcept = default;
1372
+ constexpr expected_default_ctor_base(expected_default_ctor_base const&) noexcept = default;
1373
+ constexpr expected_default_ctor_base(expected_default_ctor_base&&) noexcept = default;
1374
+ expected_default_ctor_base& operator=(expected_default_ctor_base const&) noexcept = default;
1375
+ expected_default_ctor_base& operator=(expected_default_ctor_base&&) noexcept = default;
1376
+
1377
+ constexpr explicit expected_default_ctor_base(default_constructor_tag)
1378
+ {
1379
+ }
1303
1380
  };
1304
1381
 
1305
1382
  // This specialization is for when T is not default constructible
1306
1383
  template<class T, class E>
1307
1384
  struct expected_default_ctor_base<T, E, false> {
1308
- constexpr expected_default_ctor_base() noexcept = delete;
1309
- constexpr expected_default_ctor_base(expected_default_ctor_base const&) noexcept = default;
1310
- constexpr expected_default_ctor_base(expected_default_ctor_base&&) noexcept = default;
1311
- expected_default_ctor_base& operator=(expected_default_ctor_base const&) noexcept = default;
1312
- expected_default_ctor_base& operator=(expected_default_ctor_base&&) noexcept = default;
1313
-
1314
- constexpr explicit expected_default_ctor_base(default_constructor_tag)
1315
- {
1316
- }
1385
+ constexpr expected_default_ctor_base() noexcept = delete;
1386
+ constexpr expected_default_ctor_base(expected_default_ctor_base const&) noexcept = default;
1387
+ constexpr expected_default_ctor_base(expected_default_ctor_base&&) noexcept = default;
1388
+ expected_default_ctor_base& operator=(expected_default_ctor_base const&) noexcept = default;
1389
+ expected_default_ctor_base& operator=(expected_default_ctor_base&&) noexcept = default;
1390
+
1391
+ constexpr explicit expected_default_ctor_base(default_constructor_tag)
1392
+ {
1393
+ }
1317
1394
  };
1318
1395
  } // namespace detail
1319
1396
 
1320
1397
  template<class E>
1321
1398
  class bad_expected_access : public std::exception
1322
1399
  {
1323
- public:
1324
- explicit bad_expected_access(E e)
1325
- : m_val(std::move(e))
1326
- {
1327
- }
1328
-
1329
- virtual const char* what() const noexcept override
1330
- {
1331
- return "Bad expected access";
1332
- }
1333
-
1334
- const E& error() const&
1335
- {
1336
- return m_val;
1337
- }
1338
- E& error() &
1339
- {
1340
- return m_val;
1341
- }
1342
- const E&& error() const&&
1343
- {
1344
- return std::move(m_val);
1345
- }
1346
- E&& error() &&
1347
- {
1348
- return std::move(m_val);
1349
- }
1350
-
1351
- private:
1352
- E m_val;
1400
+ public:
1401
+ explicit bad_expected_access(E e)
1402
+ : m_val(std::move(e))
1403
+ {
1404
+ }
1405
+
1406
+ virtual const char* what() const noexcept override
1407
+ {
1408
+ return "Bad expected access";
1409
+ }
1410
+
1411
+ const E& error() const&
1412
+ {
1413
+ return m_val;
1414
+ }
1415
+ E& error() &
1416
+ {
1417
+ return m_val;
1418
+ }
1419
+ const E&& error() const&&
1420
+ {
1421
+ return std::move(m_val);
1422
+ }
1423
+ E&& error() &&
1424
+ {
1425
+ return std::move(m_val);
1426
+ }
1427
+
1428
+ private:
1429
+ E m_val;
1353
1430
  };
1354
1431
 
1355
1432
  /// An `expected<T, E>` object is an object that contains the storage for
@@ -1366,781 +1443,843 @@ class expected
1366
1443
  , private detail::expected_delete_assign_base<T, E>
1367
1444
  , private detail::expected_default_ctor_base<T, E>
1368
1445
  {
1369
- static_assert(!std::is_reference<T>::value, "T must not be a reference");
1370
- static_assert(!std::is_same<T, std::remove_cv<in_place_t>::type>::value, "T must not be in_place_t");
1371
- static_assert(!std::is_same<T, std::remove_cv<unexpect_t>::type>::value, "T must not be unexpect_t");
1372
- static_assert(!std::is_same<T, typename std::remove_cv<unexpected<E>>::type>::value, "T must not be unexpected<E>");
1373
- static_assert(!std::is_reference<E>::value, "E must not be a reference");
1374
-
1375
- T* valptr()
1376
- {
1377
- return std::addressof(this->m_val);
1378
- }
1379
- const T* valptr() const
1380
- {
1381
- return std::addressof(this->m_val);
1382
- }
1383
- unexpected<E>* errptr()
1384
- {
1385
- return std::addressof(this->m_unexpect);
1386
- }
1387
- const unexpected<E>* errptr() const
1388
- {
1389
- return std::addressof(this->m_unexpect);
1390
- }
1391
-
1392
- template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
1393
- TL_EXPECTED_11_CONSTEXPR U& val()
1394
- {
1395
- return this->m_val;
1396
- }
1397
- TL_EXPECTED_11_CONSTEXPR unexpected<E>& err()
1398
- {
1399
- return this->m_unexpect;
1400
- }
1401
-
1402
- template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
1403
- constexpr const U& val() const
1404
- {
1405
- return this->m_val;
1406
- }
1407
- constexpr const unexpected<E>& err() const
1408
- {
1409
- return this->m_unexpect;
1410
- }
1411
-
1412
- using impl_base = detail::expected_move_assign_base<T, E>;
1413
- using ctor_base = detail::expected_default_ctor_base<T, E>;
1414
-
1415
- public:
1416
- typedef T value_type;
1417
- typedef E error_type;
1418
- typedef unexpected<E> unexpected_type;
1419
-
1420
- #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55)
1421
- template<class F>
1422
- TL_EXPECTED_11_CONSTEXPR auto and_then(F&& f) &
1423
- {
1424
- return and_then_impl(*this, std::forward<F>(f));
1425
- }
1426
- template<class F>
1427
- TL_EXPECTED_11_CONSTEXPR auto and_then(F&& f) &&
1428
- {
1429
- return and_then_impl(std::move(*this), std::forward<F>(f));
1430
- }
1431
- template<class F>
1432
- constexpr auto and_then(F&& f) const&
1433
- {
1434
- return and_then_impl(*this, std::forward<F>(f));
1435
- }
1446
+ static_assert(!std::is_reference<T>::value, "T must not be a reference");
1447
+ static_assert(!std::is_same<T, std::remove_cv<in_place_t>::type>::value,
1448
+ "T must not be in_place_t");
1449
+ static_assert(!std::is_same<T, std::remove_cv<unexpect_t>::type>::value,
1450
+ "T must not be unexpect_t");
1451
+ static_assert(!std::is_same<T, typename std::remove_cv<unexpected<E>>::type>::value,
1452
+ "T must not be unexpected<E>");
1453
+ static_assert(!std::is_reference<E>::value, "E must not be a reference");
1454
+
1455
+ T* valptr()
1456
+ {
1457
+ return std::addressof(this->m_val);
1458
+ }
1459
+ const T* valptr() const
1460
+ {
1461
+ return std::addressof(this->m_val);
1462
+ }
1463
+ unexpected<E>* errptr()
1464
+ {
1465
+ return std::addressof(this->m_unexpect);
1466
+ }
1467
+ const unexpected<E>* errptr() const
1468
+ {
1469
+ return std::addressof(this->m_unexpect);
1470
+ }
1471
+
1472
+ template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
1473
+ TL_EXPECTED_11_CONSTEXPR U& val()
1474
+ {
1475
+ return this->m_val;
1476
+ }
1477
+ TL_EXPECTED_11_CONSTEXPR unexpected<E>& err()
1478
+ {
1479
+ return this->m_unexpect;
1480
+ }
1481
+
1482
+ template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
1483
+ constexpr const U& val() const
1484
+ {
1485
+ return this->m_val;
1486
+ }
1487
+ constexpr const unexpected<E>& err() const
1488
+ {
1489
+ return this->m_unexpect;
1490
+ }
1491
+
1492
+ using impl_base = detail::expected_move_assign_base<T, E>;
1493
+ using ctor_base = detail::expected_default_ctor_base<T, E>;
1494
+
1495
+ public:
1496
+ typedef T value_type;
1497
+ typedef E error_type;
1498
+ typedef unexpected<E> unexpected_type;
1499
+
1500
+ #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && !defined(TL_EXPECTED_GCC54) && \
1501
+ !defined(TL_EXPECTED_GCC55)
1502
+ template<class F>
1503
+ TL_EXPECTED_11_CONSTEXPR auto and_then(F&& f) &
1504
+ {
1505
+ return and_then_impl(*this, std::forward<F>(f));
1506
+ }
1507
+ template<class F>
1508
+ TL_EXPECTED_11_CONSTEXPR auto and_then(F&& f) &&
1509
+ {
1510
+ return and_then_impl(std::move(*this), std::forward<F>(f));
1511
+ }
1512
+ template<class F>
1513
+ constexpr auto and_then(F&& f) const&
1514
+ {
1515
+ return and_then_impl(*this, std::forward<F>(f));
1516
+ }
1436
1517
 
1437
1518
  #ifndef TL_EXPECTED_NO_CONSTRR
1438
- template<class F>
1439
- constexpr auto and_then(F&& f) const&&
1440
- {
1441
- return and_then_impl(std::move(*this), std::forward<F>(f));
1442
- }
1519
+ template<class F>
1520
+ constexpr auto and_then(F&& f) const&&
1521
+ {
1522
+ return and_then_impl(std::move(*this), std::forward<F>(f));
1523
+ }
1443
1524
  #endif
1444
1525
 
1445
1526
  #else
1446
- template<class F>
1447
- TL_EXPECTED_11_CONSTEXPR auto and_then(F&& f) & -> decltype(and_then_impl(std::declval<expected&>(), std::forward<F>(f)))
1448
- {
1449
- return and_then_impl(*this, std::forward<F>(f));
1450
- }
1451
- template<class F>
1452
- TL_EXPECTED_11_CONSTEXPR auto and_then(F&& f) && -> decltype(and_then_impl(std::declval<expected&&>(), std::forward<F>(f)))
1453
- {
1454
- return and_then_impl(std::move(*this), std::forward<F>(f));
1455
- }
1456
- template<class F>
1457
- constexpr auto and_then(F&& f) const& -> decltype(and_then_impl(std::declval<expected const&>(), std::forward<F>(f)))
1458
- {
1459
- return and_then_impl(*this, std::forward<F>(f));
1460
- }
1527
+ template<class F>
1528
+ TL_EXPECTED_11_CONSTEXPR auto and_then(
1529
+ F&& f) & -> decltype(and_then_impl(std::declval<expected&>(), std::forward<F>(f)))
1530
+ {
1531
+ return and_then_impl(*this, std::forward<F>(f));
1532
+ }
1533
+ template<class F>
1534
+ TL_EXPECTED_11_CONSTEXPR auto and_then(
1535
+ F&& f) && -> decltype(and_then_impl(std::declval<expected&&>(), std::forward<F>(f)))
1536
+ {
1537
+ return and_then_impl(std::move(*this), std::forward<F>(f));
1538
+ }
1539
+ template<class F>
1540
+ constexpr auto and_then(F&& f) const& -> decltype(and_then_impl(std::declval<expected const&>(),
1541
+ std::forward<F>(f)))
1542
+ {
1543
+ return and_then_impl(*this, std::forward<F>(f));
1544
+ }
1461
1545
 
1462
1546
  #ifndef TL_EXPECTED_NO_CONSTRR
1463
- template<class F>
1464
- constexpr auto and_then(F&& f) const&& -> decltype(and_then_impl(std::declval<expected const&&>(), std::forward<F>(f)))
1465
- {
1466
- return and_then_impl(std::move(*this), std::forward<F>(f));
1467
- }
1547
+ template<class F>
1548
+ constexpr auto and_then(F&& f) const&& -> decltype(and_then_impl(std::declval<expected const&&>(),
1549
+ std::forward<F>(f)))
1550
+ {
1551
+ return and_then_impl(std::move(*this), std::forward<F>(f));
1552
+ }
1468
1553
  #endif
1469
1554
  #endif
1470
1555
 
1471
- #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55)
1472
- template<class F>
1473
- TL_EXPECTED_11_CONSTEXPR auto map(F&& f) &
1474
- {
1475
- return expected_map_impl(*this, std::forward<F>(f));
1476
- }
1477
- template<class F>
1478
- TL_EXPECTED_11_CONSTEXPR auto map(F&& f) &&
1479
- {
1480
- return expected_map_impl(std::move(*this), std::forward<F>(f));
1481
- }
1482
- template<class F>
1483
- constexpr auto map(F&& f) const&
1484
- {
1485
- return expected_map_impl(*this, std::forward<F>(f));
1486
- }
1487
- template<class F>
1488
- constexpr auto map(F&& f) const&&
1489
- {
1490
- return expected_map_impl(std::move(*this), std::forward<F>(f));
1491
- }
1556
+ #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && !defined(TL_EXPECTED_GCC54) && \
1557
+ !defined(TL_EXPECTED_GCC55)
1558
+ template<class F>
1559
+ TL_EXPECTED_11_CONSTEXPR auto map(F&& f) &
1560
+ {
1561
+ return expected_map_impl(*this, std::forward<F>(f));
1562
+ }
1563
+ template<class F>
1564
+ TL_EXPECTED_11_CONSTEXPR auto map(F&& f) &&
1565
+ {
1566
+ return expected_map_impl(std::move(*this), std::forward<F>(f));
1567
+ }
1568
+ template<class F>
1569
+ constexpr auto map(F&& f) const&
1570
+ {
1571
+ return expected_map_impl(*this, std::forward<F>(f));
1572
+ }
1573
+ template<class F>
1574
+ constexpr auto map(F&& f) const&&
1575
+ {
1576
+ return expected_map_impl(std::move(*this), std::forward<F>(f));
1577
+ }
1492
1578
  #else
1493
- template<class F>
1494
- TL_EXPECTED_11_CONSTEXPR decltype(expected_map_impl(std::declval<expected&>(), std::declval<F&&>())) map(F&& f) &
1495
- {
1496
- return expected_map_impl(*this, std::forward<F>(f));
1497
- }
1498
- template<class F>
1499
- TL_EXPECTED_11_CONSTEXPR decltype(expected_map_impl(std::declval<expected>(), std::declval<F&&>())) map(F&& f) &&
1500
- {
1501
- return expected_map_impl(std::move(*this), std::forward<F>(f));
1502
- }
1503
- template<class F>
1504
- constexpr decltype(expected_map_impl(std::declval<const expected&>(), std::declval<F&&>())) map(F&& f) const&
1505
- {
1506
- return expected_map_impl(*this, std::forward<F>(f));
1507
- }
1579
+ template<class F>
1580
+ TL_EXPECTED_11_CONSTEXPR decltype(expected_map_impl(std::declval<expected&>(),
1581
+ std::declval<F&&>()))
1582
+ map(F&& f) &
1583
+ {
1584
+ return expected_map_impl(*this, std::forward<F>(f));
1585
+ }
1586
+ template<class F>
1587
+ TL_EXPECTED_11_CONSTEXPR decltype(expected_map_impl(std::declval<expected>(),
1588
+ std::declval<F&&>()))
1589
+ map(F&& f) &&
1590
+ {
1591
+ return expected_map_impl(std::move(*this), std::forward<F>(f));
1592
+ }
1593
+ template<class F>
1594
+ constexpr decltype(expected_map_impl(std::declval<const expected&>(), std::declval<F&&>())) map(
1595
+ F&& f) const&
1596
+ {
1597
+ return expected_map_impl(*this, std::forward<F>(f));
1598
+ }
1508
1599
 
1509
1600
  #ifndef TL_EXPECTED_NO_CONSTRR
1510
- template<class F>
1511
- constexpr decltype(expected_map_impl(std::declval<const expected&&>(), std::declval<F&&>())) map(F&& f) const&&
1512
- {
1513
- return expected_map_impl(std::move(*this), std::forward<F>(f));
1514
- }
1601
+ template<class F>
1602
+ constexpr decltype(expected_map_impl(std::declval<const expected&&>(), std::declval<F&&>())) map(
1603
+ F&& f) const&&
1604
+ {
1605
+ return expected_map_impl(std::move(*this), std::forward<F>(f));
1606
+ }
1515
1607
  #endif
1516
1608
  #endif
1517
1609
 
1518
- #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55)
1519
- template<class F>
1520
- TL_EXPECTED_11_CONSTEXPR auto transform(F&& f) &
1521
- {
1522
- return expected_map_impl(*this, std::forward<F>(f));
1523
- }
1524
- template<class F>
1525
- TL_EXPECTED_11_CONSTEXPR auto transform(F&& f) &&
1526
- {
1527
- return expected_map_impl(std::move(*this), std::forward<F>(f));
1528
- }
1529
- template<class F>
1530
- constexpr auto transform(F&& f) const&
1531
- {
1532
- return expected_map_impl(*this, std::forward<F>(f));
1533
- }
1534
- template<class F>
1535
- constexpr auto transform(F&& f) const&&
1536
- {
1537
- return expected_map_impl(std::move(*this), std::forward<F>(f));
1538
- }
1610
+ #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && !defined(TL_EXPECTED_GCC54) && \
1611
+ !defined(TL_EXPECTED_GCC55)
1612
+ template<class F>
1613
+ TL_EXPECTED_11_CONSTEXPR auto transform(F&& f) &
1614
+ {
1615
+ return expected_map_impl(*this, std::forward<F>(f));
1616
+ }
1617
+ template<class F>
1618
+ TL_EXPECTED_11_CONSTEXPR auto transform(F&& f) &&
1619
+ {
1620
+ return expected_map_impl(std::move(*this), std::forward<F>(f));
1621
+ }
1622
+ template<class F>
1623
+ constexpr auto transform(F&& f) const&
1624
+ {
1625
+ return expected_map_impl(*this, std::forward<F>(f));
1626
+ }
1627
+ template<class F>
1628
+ constexpr auto transform(F&& f) const&&
1629
+ {
1630
+ return expected_map_impl(std::move(*this), std::forward<F>(f));
1631
+ }
1539
1632
  #else
1540
- template<class F>
1541
- TL_EXPECTED_11_CONSTEXPR decltype(expected_map_impl(std::declval<expected&>(), std::declval<F&&>())) transform(F&& f) &
1542
- {
1543
- return expected_map_impl(*this, std::forward<F>(f));
1544
- }
1545
- template<class F>
1546
- TL_EXPECTED_11_CONSTEXPR decltype(expected_map_impl(std::declval<expected>(), std::declval<F&&>())) transform(F&& f) &&
1547
- {
1548
- return expected_map_impl(std::move(*this), std::forward<F>(f));
1549
- }
1550
- template<class F>
1551
- constexpr decltype(expected_map_impl(std::declval<const expected&>(), std::declval<F&&>())) transform(F&& f) const&
1552
- {
1553
- return expected_map_impl(*this, std::forward<F>(f));
1554
- }
1633
+ template<class F>
1634
+ TL_EXPECTED_11_CONSTEXPR decltype(expected_map_impl(std::declval<expected&>(),
1635
+ std::declval<F&&>()))
1636
+ transform(F&& f) &
1637
+ {
1638
+ return expected_map_impl(*this, std::forward<F>(f));
1639
+ }
1640
+ template<class F>
1641
+ TL_EXPECTED_11_CONSTEXPR decltype(expected_map_impl(std::declval<expected>(),
1642
+ std::declval<F&&>()))
1643
+ transform(F&& f) &&
1644
+ {
1645
+ return expected_map_impl(std::move(*this), std::forward<F>(f));
1646
+ }
1647
+ template<class F>
1648
+ constexpr decltype(expected_map_impl(std::declval<const expected&>(), std::declval<F&&>()))
1649
+ transform(F&& f) const&
1650
+ {
1651
+ return expected_map_impl(*this, std::forward<F>(f));
1652
+ }
1555
1653
 
1556
1654
  #ifndef TL_EXPECTED_NO_CONSTRR
1557
- template<class F>
1558
- constexpr decltype(expected_map_impl(std::declval<const expected&&>(), std::declval<F&&>())) transform(F&& f) const&&
1559
- {
1560
- return expected_map_impl(std::move(*this), std::forward<F>(f));
1561
- }
1655
+ template<class F>
1656
+ constexpr decltype(expected_map_impl(std::declval<const expected&&>(), std::declval<F&&>()))
1657
+ transform(F&& f) const&&
1658
+ {
1659
+ return expected_map_impl(std::move(*this), std::forward<F>(f));
1660
+ }
1562
1661
  #endif
1563
1662
  #endif
1564
1663
 
1565
- #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55)
1566
- template<class F>
1567
- TL_EXPECTED_11_CONSTEXPR auto map_error(F&& f) &
1568
- {
1569
- return map_error_impl(*this, std::forward<F>(f));
1570
- }
1571
- template<class F>
1572
- TL_EXPECTED_11_CONSTEXPR auto map_error(F&& f) &&
1573
- {
1574
- return map_error_impl(std::move(*this), std::forward<F>(f));
1575
- }
1576
- template<class F>
1577
- constexpr auto map_error(F&& f) const&
1578
- {
1579
- return map_error_impl(*this, std::forward<F>(f));
1580
- }
1581
- template<class F>
1582
- constexpr auto map_error(F&& f) const&&
1583
- {
1584
- return map_error_impl(std::move(*this), std::forward<F>(f));
1585
- }
1664
+ #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && !defined(TL_EXPECTED_GCC54) && \
1665
+ !defined(TL_EXPECTED_GCC55)
1666
+ template<class F>
1667
+ TL_EXPECTED_11_CONSTEXPR auto map_error(F&& f) &
1668
+ {
1669
+ return map_error_impl(*this, std::forward<F>(f));
1670
+ }
1671
+ template<class F>
1672
+ TL_EXPECTED_11_CONSTEXPR auto map_error(F&& f) &&
1673
+ {
1674
+ return map_error_impl(std::move(*this), std::forward<F>(f));
1675
+ }
1676
+ template<class F>
1677
+ constexpr auto map_error(F&& f) const&
1678
+ {
1679
+ return map_error_impl(*this, std::forward<F>(f));
1680
+ }
1681
+ template<class F>
1682
+ constexpr auto map_error(F&& f) const&&
1683
+ {
1684
+ return map_error_impl(std::move(*this), std::forward<F>(f));
1685
+ }
1586
1686
  #else
1587
- template<class F>
1588
- TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval<expected&>(), std::declval<F&&>())) map_error(F&& f) &
1589
- {
1590
- return map_error_impl(*this, std::forward<F>(f));
1591
- }
1592
- template<class F>
1593
- TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval<expected&&>(), std::declval<F&&>())) map_error(F&& f) &&
1594
- {
1595
- return map_error_impl(std::move(*this), std::forward<F>(f));
1596
- }
1597
- template<class F>
1598
- constexpr decltype(map_error_impl(std::declval<const expected&>(), std::declval<F&&>())) map_error(F&& f) const&
1599
- {
1600
- return map_error_impl(*this, std::forward<F>(f));
1601
- }
1687
+ template<class F>
1688
+ TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval<expected&>(), std::declval<F&&>()))
1689
+ map_error(F&& f) &
1690
+ {
1691
+ return map_error_impl(*this, std::forward<F>(f));
1692
+ }
1693
+ template<class F>
1694
+ TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval<expected&&>(), std::declval<F&&>()))
1695
+ map_error(F&& f) &&
1696
+ {
1697
+ return map_error_impl(std::move(*this), std::forward<F>(f));
1698
+ }
1699
+ template<class F>
1700
+ constexpr decltype(map_error_impl(std::declval<const expected&>(), std::declval<F&&>()))
1701
+ map_error(F&& f) const&
1702
+ {
1703
+ return map_error_impl(*this, std::forward<F>(f));
1704
+ }
1602
1705
 
1603
1706
  #ifndef TL_EXPECTED_NO_CONSTRR
1604
- template<class F>
1605
- constexpr decltype(map_error_impl(std::declval<const expected&&>(), std::declval<F&&>())) map_error(F&& f) const&&
1606
- {
1607
- return map_error_impl(std::move(*this), std::forward<F>(f));
1608
- }
1707
+ template<class F>
1708
+ constexpr decltype(map_error_impl(std::declval<const expected&&>(), std::declval<F&&>()))
1709
+ map_error(F&& f) const&&
1710
+ {
1711
+ return map_error_impl(std::move(*this), std::forward<F>(f));
1712
+ }
1609
1713
  #endif
1610
1714
  #endif
1611
- template<class F>
1612
- expected TL_EXPECTED_11_CONSTEXPR or_else(F&& f) &
1613
- {
1614
- return or_else_impl(*this, std::forward<F>(f));
1615
- }
1616
-
1617
- template<class F>
1618
- expected TL_EXPECTED_11_CONSTEXPR or_else(F&& f) &&
1619
- {
1620
- return or_else_impl(std::move(*this), std::forward<F>(f));
1621
- }
1622
-
1623
- template<class F>
1624
- expected constexpr or_else(F&& f) const&
1625
- {
1626
- return or_else_impl(*this, std::forward<F>(f));
1627
- }
1715
+ template<class F>
1716
+ expected TL_EXPECTED_11_CONSTEXPR or_else(F&& f) &
1717
+ {
1718
+ return or_else_impl(*this, std::forward<F>(f));
1719
+ }
1720
+
1721
+ template<class F>
1722
+ expected TL_EXPECTED_11_CONSTEXPR or_else(F&& f) &&
1723
+ {
1724
+ return or_else_impl(std::move(*this), std::forward<F>(f));
1725
+ }
1726
+
1727
+ template<class F>
1728
+ expected constexpr or_else(F&& f) const&
1729
+ {
1730
+ return or_else_impl(*this, std::forward<F>(f));
1731
+ }
1628
1732
 
1629
1733
  #ifndef TL_EXPECTED_NO_CONSTRR
1630
- template<class F>
1631
- expected constexpr or_else(F&& f) const&&
1632
- {
1633
- return or_else_impl(std::move(*this), std::forward<F>(f));
1634
- }
1734
+ template<class F>
1735
+ expected constexpr or_else(F&& f) const&&
1736
+ {
1737
+ return or_else_impl(std::move(*this), std::forward<F>(f));
1738
+ }
1635
1739
  #endif
1636
- constexpr expected() = default;
1637
- constexpr expected(const expected& rhs) = default;
1638
- constexpr expected(expected&& rhs) = default;
1639
- expected& operator=(const expected& rhs) = default;
1640
- expected& operator=(expected&& rhs) = default;
1641
-
1642
- template<class... Args, detail::enable_if_t<std::is_constructible<T, Args&&...>::value>* = nullptr>
1643
- constexpr expected(in_place_t, Args&&... args)
1644
- : impl_base(in_place, std::forward<Args>(args)...)
1645
- , ctor_base(detail::default_constructor_tag{})
1646
- {
1647
- }
1648
-
1649
- template<class U, class... Args, detail::enable_if_t<std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
1650
- constexpr expected(in_place_t, std::initializer_list<U> il, Args&&... args)
1651
- : impl_base(in_place, il, std::forward<Args>(args)...)
1652
- , ctor_base(detail::default_constructor_tag{})
1653
- {
1654
- }
1655
-
1656
- template<class G = E,
1657
- detail::enable_if_t<std::is_constructible<E, const G&>::value>* = nullptr,
1658
- detail::enable_if_t<!std::is_convertible<const G&, E>::value>* = nullptr>
1659
- explicit constexpr expected(const unexpected<G>& e)
1660
- : impl_base(unexpect, e.value())
1661
- , ctor_base(detail::default_constructor_tag{})
1662
- {
1663
- }
1664
-
1665
- template<class G = E,
1666
- detail::enable_if_t<std::is_constructible<E, const G&>::value>* = nullptr,
1667
- detail::enable_if_t<std::is_convertible<const G&, E>::value>* = nullptr>
1668
- constexpr expected(unexpected<G> const& e)
1669
- : impl_base(unexpect, e.value())
1670
- , ctor_base(detail::default_constructor_tag{})
1671
- {
1672
- }
1673
-
1674
- template<class G = E,
1675
- detail::enable_if_t<std::is_constructible<E, G&&>::value>* = nullptr,
1676
- detail::enable_if_t<!std::is_convertible<G&&, E>::value>* = nullptr>
1677
- explicit constexpr expected(unexpected<G>&& e) noexcept(std::is_nothrow_constructible<E, G&&>::value)
1678
- : impl_base(unexpect, std::move(e.value()))
1679
- , ctor_base(detail::default_constructor_tag{})
1680
- {
1681
- }
1682
-
1683
- template<class G = E,
1684
- detail::enable_if_t<std::is_constructible<E, G&&>::value>* = nullptr,
1685
- detail::enable_if_t<std::is_convertible<G&&, E>::value>* = nullptr>
1686
- constexpr expected(unexpected<G>&& e) noexcept(std::is_nothrow_constructible<E, G&&>::value)
1687
- : impl_base(unexpect, std::move(e.value()))
1688
- , ctor_base(detail::default_constructor_tag{})
1689
- {
1690
- }
1691
-
1692
- template<class... Args, detail::enable_if_t<std::is_constructible<E, Args&&...>::value>* = nullptr>
1693
- constexpr explicit expected(unexpect_t, Args&&... args)
1694
- : impl_base(unexpect, std::forward<Args>(args)...)
1695
- , ctor_base(detail::default_constructor_tag{})
1696
- {
1697
- }
1698
-
1699
- template<class U, class... Args, detail::enable_if_t<std::is_constructible<E, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
1700
- constexpr explicit expected(unexpect_t, std::initializer_list<U> il, Args&&... args)
1701
- : impl_base(unexpect, il, std::forward<Args>(args)...)
1702
- , ctor_base(detail::default_constructor_tag{})
1703
- {
1704
- }
1705
-
1706
- template<class U,
1707
- class G,
1708
- detail::enable_if_t<!(std::is_convertible<U const&, T>::value && std::is_convertible<G const&, E>::value)>* = nullptr,
1709
- detail::expected_enable_from_other<T, E, U, G, const U&, const G&>* = nullptr>
1710
- explicit TL_EXPECTED_11_CONSTEXPR expected(const expected<U, G>& rhs)
1711
- : ctor_base(detail::default_constructor_tag{})
1712
- {
1713
- if (rhs.has_value()) {
1714
- this->construct(*rhs);
1715
- } else {
1716
- this->construct_error(rhs.error());
1717
- }
1718
- }
1719
-
1720
- template<class U,
1721
- class G,
1722
- detail::enable_if_t<(std::is_convertible<U const&, T>::value && std::is_convertible<G const&, E>::value)>* = nullptr,
1723
- detail::expected_enable_from_other<T, E, U, G, const U&, const G&>* = nullptr>
1724
- TL_EXPECTED_11_CONSTEXPR expected(const expected<U, G>& rhs)
1725
- : ctor_base(detail::default_constructor_tag{})
1726
- {
1727
- if (rhs.has_value()) {
1728
- this->construct(*rhs);
1729
- } else {
1730
- this->construct_error(rhs.error());
1731
- }
1732
- }
1733
-
1734
- template<class U,
1735
- class G,
1736
- detail::enable_if_t<!(std::is_convertible<U&&, T>::value && std::is_convertible<G&&, E>::value)>* = nullptr,
1737
- detail::expected_enable_from_other<T, E, U, G, U&&, G&&>* = nullptr>
1738
- explicit TL_EXPECTED_11_CONSTEXPR expected(expected<U, G>&& rhs)
1739
- : ctor_base(detail::default_constructor_tag{})
1740
- {
1741
- if (rhs.has_value()) {
1742
- this->construct(std::move(*rhs));
1743
- } else {
1744
- this->construct_error(std::move(rhs.error()));
1745
- }
1746
- }
1747
-
1748
- template<class U,
1749
- class G,
1750
- detail::enable_if_t<(std::is_convertible<U&&, T>::value && std::is_convertible<G&&, E>::value)>* = nullptr,
1751
- detail::expected_enable_from_other<T, E, U, G, U&&, G&&>* = nullptr>
1752
- TL_EXPECTED_11_CONSTEXPR expected(expected<U, G>&& rhs)
1753
- : ctor_base(detail::default_constructor_tag{})
1754
- {
1755
- if (rhs.has_value()) {
1756
- this->construct(std::move(*rhs));
1757
- } else {
1758
- this->construct_error(std::move(rhs.error()));
1759
- }
1760
- }
1761
-
1762
- template<class U = T,
1763
- detail::enable_if_t<!std::is_convertible<U&&, T>::value>* = nullptr,
1764
- detail::expected_enable_forward_value<T, E, U>* = nullptr>
1765
- explicit TL_EXPECTED_MSVC2015_CONSTEXPR expected(U&& v)
1766
- : expected(in_place, std::forward<U>(v))
1767
- {
1768
- }
1769
-
1770
- template<class U = T,
1771
- detail::enable_if_t<std::is_convertible<U&&, T>::value>* = nullptr,
1772
- detail::expected_enable_forward_value<T, E, U>* = nullptr>
1773
- TL_EXPECTED_MSVC2015_CONSTEXPR expected(U&& v)
1774
- : expected(in_place, std::forward<U>(v))
1775
- {
1776
- }
1777
-
1778
- template<class U = T,
1779
- class G = T,
1780
- detail::enable_if_t<std::is_nothrow_constructible<T, U&&>::value>* = nullptr,
1781
- detail::enable_if_t<!std::is_void<G>::value>* = nullptr,
1782
- detail::enable_if_t<(!std::is_same<expected<T, E>, detail::decay_t<U>>::value &&
1783
- !detail::conjunction<std::is_scalar<T>, std::is_same<T, detail::decay_t<U>>>::value &&
1784
- std::is_constructible<T, U>::value && std::is_assignable<G&, U>::value &&
1785
- std::is_nothrow_move_constructible<E>::value)>* = nullptr>
1786
- expected& operator=(U&& v)
1787
- {
1788
- if (has_value()) {
1789
- val() = std::forward<U>(v);
1790
- } else {
1791
- err().~unexpected<E>();
1792
- ::new (valptr()) T(std::forward<U>(v));
1793
- this->m_has_val = true;
1794
- }
1795
-
1796
- return *this;
1797
- }
1798
-
1799
- template<class U = T,
1800
- class G = T,
1801
- detail::enable_if_t<!std::is_nothrow_constructible<T, U&&>::value>* = nullptr,
1802
- detail::enable_if_t<!std::is_void<U>::value>* = nullptr,
1803
- detail::enable_if_t<(!std::is_same<expected<T, E>, detail::decay_t<U>>::value &&
1804
- !detail::conjunction<std::is_scalar<T>, std::is_same<T, detail::decay_t<U>>>::value &&
1805
- std::is_constructible<T, U>::value && std::is_assignable<G&, U>::value &&
1806
- std::is_nothrow_move_constructible<E>::value)>* = nullptr>
1807
- expected& operator=(U&& v)
1808
- {
1809
- if (has_value()) {
1810
- val() = std::forward<U>(v);
1811
- } else {
1812
- auto tmp = std::move(err());
1813
- err().~unexpected<E>();
1740
+ constexpr expected() = default;
1741
+ constexpr expected(const expected& rhs) = default;
1742
+ constexpr expected(expected&& rhs) = default;
1743
+ expected& operator=(const expected& rhs) = default;
1744
+ expected& operator=(expected&& rhs) = default;
1745
+
1746
+ template<class... Args,
1747
+ detail::enable_if_t<std::is_constructible<T, Args&&...>::value>* = nullptr>
1748
+ constexpr expected(in_place_t, Args&&... args)
1749
+ : impl_base(in_place, std::forward<Args>(args)...)
1750
+ , ctor_base(detail::default_constructor_tag{})
1751
+ {
1752
+ }
1753
+
1754
+ template<class U,
1755
+ class... Args,
1756
+ detail::enable_if_t<
1757
+ std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
1758
+ constexpr expected(in_place_t, std::initializer_list<U> il, Args&&... args)
1759
+ : impl_base(in_place, il, std::forward<Args>(args)...)
1760
+ , ctor_base(detail::default_constructor_tag{})
1761
+ {
1762
+ }
1763
+
1764
+ template<class G = E,
1765
+ detail::enable_if_t<std::is_constructible<E, const G&>::value>* = nullptr,
1766
+ detail::enable_if_t<!std::is_convertible<const G&, E>::value>* = nullptr>
1767
+ explicit constexpr expected(const unexpected<G>& e)
1768
+ : impl_base(unexpect, e.value())
1769
+ , ctor_base(detail::default_constructor_tag{})
1770
+ {
1771
+ }
1772
+
1773
+ template<class G = E,
1774
+ detail::enable_if_t<std::is_constructible<E, const G&>::value>* = nullptr,
1775
+ detail::enable_if_t<std::is_convertible<const G&, E>::value>* = nullptr>
1776
+ constexpr expected(unexpected<G> const& e)
1777
+ : impl_base(unexpect, e.value())
1778
+ , ctor_base(detail::default_constructor_tag{})
1779
+ {
1780
+ }
1781
+
1782
+ template<class G = E,
1783
+ detail::enable_if_t<std::is_constructible<E, G&&>::value>* = nullptr,
1784
+ detail::enable_if_t<!std::is_convertible<G&&, E>::value>* = nullptr>
1785
+ explicit constexpr expected(unexpected<G>&& e) noexcept(
1786
+ std::is_nothrow_constructible<E, G&&>::value)
1787
+ : impl_base(unexpect, std::move(e.value()))
1788
+ , ctor_base(detail::default_constructor_tag{})
1789
+ {
1790
+ }
1791
+
1792
+ template<class G = E,
1793
+ detail::enable_if_t<std::is_constructible<E, G&&>::value>* = nullptr,
1794
+ detail::enable_if_t<std::is_convertible<G&&, E>::value>* = nullptr>
1795
+ constexpr expected(unexpected<G>&& e) noexcept(std::is_nothrow_constructible<E, G&&>::value)
1796
+ : impl_base(unexpect, std::move(e.value()))
1797
+ , ctor_base(detail::default_constructor_tag{})
1798
+ {
1799
+ }
1800
+
1801
+ template<class... Args,
1802
+ detail::enable_if_t<std::is_constructible<E, Args&&...>::value>* = nullptr>
1803
+ constexpr explicit expected(unexpect_t, Args&&... args)
1804
+ : impl_base(unexpect, std::forward<Args>(args)...)
1805
+ , ctor_base(detail::default_constructor_tag{})
1806
+ {
1807
+ }
1808
+
1809
+ template<class U,
1810
+ class... Args,
1811
+ detail::enable_if_t<
1812
+ std::is_constructible<E, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
1813
+ constexpr explicit expected(unexpect_t, std::initializer_list<U> il, Args&&... args)
1814
+ : impl_base(unexpect, il, std::forward<Args>(args)...)
1815
+ , ctor_base(detail::default_constructor_tag{})
1816
+ {
1817
+ }
1818
+
1819
+ template<class U,
1820
+ class G,
1821
+ detail::enable_if_t<!(std::is_convertible<U const&, T>::value &&
1822
+ std::is_convertible<G const&, E>::value)>* = nullptr,
1823
+ detail::expected_enable_from_other<T, E, U, G, const U&, const G&>* = nullptr>
1824
+ explicit TL_EXPECTED_11_CONSTEXPR expected(const expected<U, G>& rhs)
1825
+ : ctor_base(detail::default_constructor_tag{})
1826
+ {
1827
+ if (rhs.has_value()) {
1828
+ this->construct(*rhs);
1829
+ } else {
1830
+ this->construct_error(rhs.error());
1831
+ }
1832
+ }
1833
+
1834
+ template<class U,
1835
+ class G,
1836
+ detail::enable_if_t<(std::is_convertible<U const&, T>::value &&
1837
+ std::is_convertible<G const&, E>::value)>* = nullptr,
1838
+ detail::expected_enable_from_other<T, E, U, G, const U&, const G&>* = nullptr>
1839
+ TL_EXPECTED_11_CONSTEXPR expected(const expected<U, G>& rhs)
1840
+ : ctor_base(detail::default_constructor_tag{})
1841
+ {
1842
+ if (rhs.has_value()) {
1843
+ this->construct(*rhs);
1844
+ } else {
1845
+ this->construct_error(rhs.error());
1846
+ }
1847
+ }
1848
+
1849
+ template<class U,
1850
+ class G,
1851
+ detail::enable_if_t<!(std::is_convertible<U&&, T>::value &&
1852
+ std::is_convertible<G&&, E>::value)>* = nullptr,
1853
+ detail::expected_enable_from_other<T, E, U, G, U&&, G&&>* = nullptr>
1854
+ explicit TL_EXPECTED_11_CONSTEXPR expected(expected<U, G>&& rhs)
1855
+ : ctor_base(detail::default_constructor_tag{})
1856
+ {
1857
+ if (rhs.has_value()) {
1858
+ this->construct(std::move(*rhs));
1859
+ } else {
1860
+ this->construct_error(std::move(rhs.error()));
1861
+ }
1862
+ }
1863
+
1864
+ template<class U,
1865
+ class G,
1866
+ detail::enable_if_t<(std::is_convertible<U&&, T>::value &&
1867
+ std::is_convertible<G&&, E>::value)>* = nullptr,
1868
+ detail::expected_enable_from_other<T, E, U, G, U&&, G&&>* = nullptr>
1869
+ TL_EXPECTED_11_CONSTEXPR expected(expected<U, G>&& rhs)
1870
+ : ctor_base(detail::default_constructor_tag{})
1871
+ {
1872
+ if (rhs.has_value()) {
1873
+ this->construct(std::move(*rhs));
1874
+ } else {
1875
+ this->construct_error(std::move(rhs.error()));
1876
+ }
1877
+ }
1878
+
1879
+ template<class U = T,
1880
+ detail::enable_if_t<!std::is_convertible<U&&, T>::value>* = nullptr,
1881
+ detail::expected_enable_forward_value<T, E, U>* = nullptr>
1882
+ explicit TL_EXPECTED_MSVC2015_CONSTEXPR expected(U&& v)
1883
+ : expected(in_place, std::forward<U>(v))
1884
+ {
1885
+ }
1886
+
1887
+ template<class U = T,
1888
+ detail::enable_if_t<std::is_convertible<U&&, T>::value>* = nullptr,
1889
+ detail::expected_enable_forward_value<T, E, U>* = nullptr>
1890
+ TL_EXPECTED_MSVC2015_CONSTEXPR expected(U&& v)
1891
+ : expected(in_place, std::forward<U>(v))
1892
+ {
1893
+ }
1894
+
1895
+ template<class U = T,
1896
+ class G = T,
1897
+ detail::enable_if_t<std::is_nothrow_constructible<T, U&&>::value>* = nullptr,
1898
+ detail::enable_if_t<!std::is_void<G>::value>* = nullptr,
1899
+ detail::enable_if_t<
1900
+ (!std::is_same<expected<T, E>, detail::decay_t<U>>::value &&
1901
+ !detail::conjunction<std::is_scalar<T>, std::is_same<T, detail::decay_t<U>>>::value &&
1902
+ std::is_constructible<T, U>::value && std::is_assignable<G&, U>::value &&
1903
+ std::is_nothrow_move_constructible<E>::value)>* = nullptr>
1904
+ expected& operator=(U&& v)
1905
+ {
1906
+ if (has_value()) {
1907
+ val() = std::forward<U>(v);
1908
+ } else {
1909
+ err().~unexpected<E>();
1910
+ ::new (valptr()) T(std::forward<U>(v));
1911
+ this->m_has_val = true;
1912
+ }
1913
+
1914
+ return *this;
1915
+ }
1916
+
1917
+ template<class U = T,
1918
+ class G = T,
1919
+ detail::enable_if_t<!std::is_nothrow_constructible<T, U&&>::value>* = nullptr,
1920
+ detail::enable_if_t<!std::is_void<U>::value>* = nullptr,
1921
+ detail::enable_if_t<
1922
+ (!std::is_same<expected<T, E>, detail::decay_t<U>>::value &&
1923
+ !detail::conjunction<std::is_scalar<T>, std::is_same<T, detail::decay_t<U>>>::value &&
1924
+ std::is_constructible<T, U>::value && std::is_assignable<G&, U>::value &&
1925
+ std::is_nothrow_move_constructible<E>::value)>* = nullptr>
1926
+ expected& operator=(U&& v)
1927
+ {
1928
+ if (has_value()) {
1929
+ val() = std::forward<U>(v);
1930
+ } else {
1931
+ auto tmp = std::move(err());
1932
+ err().~unexpected<E>();
1814
1933
 
1815
1934
  #ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
1816
- try {
1817
- ::new (valptr()) T(std::forward<U>(v));
1818
- this->m_has_val = true;
1819
- } catch (...) {
1820
- err() = std::move(tmp);
1821
- throw;
1822
- }
1935
+ try {
1936
+ ::new (valptr()) T(std::forward<U>(v));
1937
+ this->m_has_val = true;
1938
+ } catch (...) {
1939
+ err() = std::move(tmp);
1940
+ throw;
1941
+ }
1823
1942
  #else
1824
- ::new (valptr()) T(std::forward<U>(v));
1825
- this->m_has_val = true;
1943
+ ::new (valptr()) T(std::forward<U>(v));
1944
+ this->m_has_val = true;
1826
1945
  #endif
1827
- }
1828
-
1829
- return *this;
1830
1946
  }
1831
1947
 
1832
- template<class G = E, detail::enable_if_t<std::is_nothrow_copy_constructible<G>::value && std::is_assignable<G&, G>::value>* = nullptr>
1833
- expected& operator=(const unexpected<G>& rhs)
1834
- {
1835
- if (!has_value()) {
1836
- err() = rhs;
1837
- } else {
1838
- this->destroy_val();
1839
- ::new (errptr()) unexpected<E>(rhs);
1840
- this->m_has_val = false;
1841
- }
1842
-
1843
- return *this;
1844
- }
1845
-
1846
- template<class G = E, detail::enable_if_t<std::is_nothrow_move_constructible<G>::value && std::is_move_assignable<G>::value>* = nullptr>
1847
- expected& operator=(unexpected<G>&& rhs) noexcept
1848
- {
1849
- if (!has_value()) {
1850
- err() = std::move(rhs);
1851
- } else {
1852
- this->destroy_val();
1853
- ::new (errptr()) unexpected<E>(std::move(rhs));
1854
- this->m_has_val = false;
1855
- }
1856
-
1857
- return *this;
1858
- }
1859
-
1860
- template<class... Args, detail::enable_if_t<std::is_nothrow_constructible<T, Args&&...>::value>* = nullptr>
1861
- void emplace(Args&&... args)
1862
- {
1863
- if (has_value()) {
1864
- val() = T(std::forward<Args>(args)...);
1865
- } else {
1866
- err().~unexpected<E>();
1867
- ::new (valptr()) T(std::forward<Args>(args)...);
1868
- this->m_has_val = true;
1869
- }
1870
- }
1871
-
1872
- template<class... Args, detail::enable_if_t<!std::is_nothrow_constructible<T, Args&&...>::value>* = nullptr>
1873
- void emplace(Args&&... args)
1874
- {
1875
- if (has_value()) {
1876
- val() = T(std::forward<Args>(args)...);
1877
- } else {
1878
- auto tmp = std::move(err());
1879
- err().~unexpected<E>();
1948
+ return *this;
1949
+ }
1950
+
1951
+ template<class G = E,
1952
+ detail::enable_if_t<std::is_nothrow_copy_constructible<G>::value &&
1953
+ std::is_assignable<G&, G>::value>* = nullptr>
1954
+ expected& operator=(const unexpected<G>& rhs)
1955
+ {
1956
+ if (!has_value()) {
1957
+ err() = rhs;
1958
+ } else {
1959
+ this->destroy_val();
1960
+ ::new (errptr()) unexpected<E>(rhs);
1961
+ this->m_has_val = false;
1962
+ }
1963
+
1964
+ return *this;
1965
+ }
1966
+
1967
+ template<class G = E,
1968
+ detail::enable_if_t<std::is_nothrow_move_constructible<G>::value &&
1969
+ std::is_move_assignable<G>::value>* = nullptr>
1970
+ expected& operator=(unexpected<G>&& rhs) noexcept
1971
+ {
1972
+ if (!has_value()) {
1973
+ err() = std::move(rhs);
1974
+ } else {
1975
+ this->destroy_val();
1976
+ ::new (errptr()) unexpected<E>(std::move(rhs));
1977
+ this->m_has_val = false;
1978
+ }
1979
+
1980
+ return *this;
1981
+ }
1982
+
1983
+ template<class... Args,
1984
+ detail::enable_if_t<std::is_nothrow_constructible<T, Args&&...>::value>* = nullptr>
1985
+ void emplace(Args&&... args)
1986
+ {
1987
+ if (has_value()) {
1988
+ val() = T(std::forward<Args>(args)...);
1989
+ } else {
1990
+ err().~unexpected<E>();
1991
+ ::new (valptr()) T(std::forward<Args>(args)...);
1992
+ this->m_has_val = true;
1993
+ }
1994
+ }
1995
+
1996
+ template<class... Args,
1997
+ detail::enable_if_t<!std::is_nothrow_constructible<T, Args&&...>::value>* = nullptr>
1998
+ void emplace(Args&&... args)
1999
+ {
2000
+ if (has_value()) {
2001
+ val() = T(std::forward<Args>(args)...);
2002
+ } else {
2003
+ auto tmp = std::move(err());
2004
+ err().~unexpected<E>();
1880
2005
 
1881
2006
  #ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
1882
- try {
1883
- ::new (valptr()) T(std::forward<Args>(args)...);
1884
- this->m_has_val = true;
1885
- } catch (...) {
1886
- err() = std::move(tmp);
1887
- throw;
1888
- }
2007
+ try {
2008
+ ::new (valptr()) T(std::forward<Args>(args)...);
2009
+ this->m_has_val = true;
2010
+ } catch (...) {
2011
+ err() = std::move(tmp);
2012
+ throw;
2013
+ }
1889
2014
  #else
1890
- ::new (valptr()) T(std::forward<Args>(args)...);
1891
- this->m_has_val = true;
2015
+ ::new (valptr()) T(std::forward<Args>(args)...);
2016
+ this->m_has_val = true;
1892
2017
  #endif
1893
- }
1894
- }
1895
-
1896
- template<class U,
1897
- class... Args,
1898
- detail::enable_if_t<std::is_nothrow_constructible<T, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
1899
- void emplace(std::initializer_list<U> il, Args&&... args)
1900
- {
1901
- if (has_value()) {
1902
- T t(il, std::forward<Args>(args)...);
1903
- val() = std::move(t);
1904
- } else {
1905
- err().~unexpected<E>();
1906
- ::new (valptr()) T(il, std::forward<Args>(args)...);
1907
- this->m_has_val = true;
1908
- }
1909
2018
  }
1910
-
1911
- template<class U,
1912
- class... Args,
1913
- detail::enable_if_t<!std::is_nothrow_constructible<T, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
1914
- void emplace(std::initializer_list<U> il, Args&&... args)
1915
- {
1916
- if (has_value()) {
1917
- T t(il, std::forward<Args>(args)...);
1918
- val() = std::move(t);
1919
- } else {
1920
- auto tmp = std::move(err());
1921
- err().~unexpected<E>();
2019
+ }
2020
+
2021
+ template<
2022
+ class U,
2023
+ class... Args,
2024
+ detail::enable_if_t<
2025
+ std::is_nothrow_constructible<T, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
2026
+ void emplace(std::initializer_list<U> il, Args&&... args)
2027
+ {
2028
+ if (has_value()) {
2029
+ T t(il, std::forward<Args>(args)...);
2030
+ val() = std::move(t);
2031
+ } else {
2032
+ err().~unexpected<E>();
2033
+ ::new (valptr()) T(il, std::forward<Args>(args)...);
2034
+ this->m_has_val = true;
2035
+ }
2036
+ }
2037
+
2038
+ template<
2039
+ class U,
2040
+ class... Args,
2041
+ detail::enable_if_t<
2042
+ !std::is_nothrow_constructible<T, std::initializer_list<U>&, Args&&...>::value>* = nullptr>
2043
+ void emplace(std::initializer_list<U> il, Args&&... args)
2044
+ {
2045
+ if (has_value()) {
2046
+ T t(il, std::forward<Args>(args)...);
2047
+ val() = std::move(t);
2048
+ } else {
2049
+ auto tmp = std::move(err());
2050
+ err().~unexpected<E>();
1922
2051
 
1923
2052
  #ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
1924
- try {
1925
- ::new (valptr()) T(il, std::forward<Args>(args)...);
1926
- this->m_has_val = true;
1927
- } catch (...) {
1928
- err() = std::move(tmp);
1929
- throw;
1930
- }
2053
+ try {
2054
+ ::new (valptr()) T(il, std::forward<Args>(args)...);
2055
+ this->m_has_val = true;
2056
+ } catch (...) {
2057
+ err() = std::move(tmp);
2058
+ throw;
2059
+ }
1931
2060
  #else
1932
- ::new (valptr()) T(il, std::forward<Args>(args)...);
1933
- this->m_has_val = true;
2061
+ ::new (valptr()) T(il, std::forward<Args>(args)...);
2062
+ this->m_has_val = true;
1934
2063
  #endif
1935
- }
1936
- }
1937
-
1938
- private:
1939
- using t_is_void = std::true_type;
1940
- using t_is_not_void = std::false_type;
1941
- using t_is_nothrow_move_constructible = std::true_type;
1942
- using move_constructing_t_can_throw = std::false_type;
1943
- using e_is_nothrow_move_constructible = std::true_type;
1944
- using move_constructing_e_can_throw = std::false_type;
1945
-
1946
- void swap_where_both_have_value(expected& /*rhs*/, t_is_void) noexcept
1947
- {
1948
- // swapping void is a no-op
1949
- }
1950
-
1951
- void swap_where_both_have_value(expected& rhs, t_is_not_void)
1952
- {
1953
- using std::swap;
1954
- swap(val(), rhs.val());
1955
2064
  }
1956
-
1957
- void swap_where_only_one_has_value(expected& rhs, t_is_void) noexcept(std::is_nothrow_move_constructible<E>::value)
1958
- {
1959
- ::new (errptr()) unexpected_type(std::move(rhs.err()));
1960
- rhs.err().~unexpected_type();
1961
- std::swap(this->m_has_val, rhs.m_has_val);
1962
- }
1963
-
1964
- void swap_where_only_one_has_value(expected& rhs, t_is_not_void)
1965
- {
1966
- swap_where_only_one_has_value_and_t_is_not_void(
1967
- rhs, typename std::is_nothrow_move_constructible<T>::type{}, typename std::is_nothrow_move_constructible<E>::type{});
1968
- }
1969
-
1970
- void swap_where_only_one_has_value_and_t_is_not_void(expected& rhs,
1971
- t_is_nothrow_move_constructible,
1972
- e_is_nothrow_move_constructible) noexcept
1973
- {
1974
- auto temp = std::move(val());
1975
- val().~T();
1976
- ::new (errptr()) unexpected_type(std::move(rhs.err()));
1977
- rhs.err().~unexpected_type();
1978
- ::new (rhs.valptr()) T(std::move(temp));
1979
- std::swap(this->m_has_val, rhs.m_has_val);
1980
- }
1981
-
1982
- void swap_where_only_one_has_value_and_t_is_not_void(expected& rhs, t_is_nothrow_move_constructible, move_constructing_e_can_throw)
1983
- {
1984
- auto temp = std::move(val());
1985
- val().~T();
2065
+ }
2066
+
2067
+ private:
2068
+ using t_is_void = std::true_type;
2069
+ using t_is_not_void = std::false_type;
2070
+ using t_is_nothrow_move_constructible = std::true_type;
2071
+ using move_constructing_t_can_throw = std::false_type;
2072
+ using e_is_nothrow_move_constructible = std::true_type;
2073
+ using move_constructing_e_can_throw = std::false_type;
2074
+
2075
+ void swap_where_both_have_value(expected& /*rhs*/, t_is_void) noexcept
2076
+ {
2077
+ // swapping void is a no-op
2078
+ }
2079
+
2080
+ void swap_where_both_have_value(expected& rhs, t_is_not_void)
2081
+ {
2082
+ using std::swap;
2083
+ swap(val(), rhs.val());
2084
+ }
2085
+
2086
+ void swap_where_only_one_has_value(expected& rhs, t_is_void) noexcept(
2087
+ std::is_nothrow_move_constructible<E>::value)
2088
+ {
2089
+ ::new (errptr()) unexpected_type(std::move(rhs.err()));
2090
+ rhs.err().~unexpected_type();
2091
+ std::swap(this->m_has_val, rhs.m_has_val);
2092
+ }
2093
+
2094
+ void swap_where_only_one_has_value(expected& rhs, t_is_not_void)
2095
+ {
2096
+ swap_where_only_one_has_value_and_t_is_not_void(
2097
+ rhs,
2098
+ typename std::is_nothrow_move_constructible<T>::type{},
2099
+ typename std::is_nothrow_move_constructible<E>::type{});
2100
+ }
2101
+
2102
+ void swap_where_only_one_has_value_and_t_is_not_void(expected& rhs,
2103
+ t_is_nothrow_move_constructible,
2104
+ e_is_nothrow_move_constructible) noexcept
2105
+ {
2106
+ auto temp = std::move(val());
2107
+ val().~T();
2108
+ ::new (errptr()) unexpected_type(std::move(rhs.err()));
2109
+ rhs.err().~unexpected_type();
2110
+ ::new (rhs.valptr()) T(std::move(temp));
2111
+ std::swap(this->m_has_val, rhs.m_has_val);
2112
+ }
2113
+
2114
+ void swap_where_only_one_has_value_and_t_is_not_void(expected& rhs,
2115
+ t_is_nothrow_move_constructible,
2116
+ move_constructing_e_can_throw)
2117
+ {
2118
+ auto temp = std::move(val());
2119
+ val().~T();
1986
2120
  #ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
1987
- try {
1988
- ::new (errptr()) unexpected_type(std::move(rhs.err()));
1989
- rhs.err().~unexpected_type();
1990
- ::new (rhs.valptr()) T(std::move(temp));
1991
- std::swap(this->m_has_val, rhs.m_has_val);
1992
- } catch (...) {
1993
- val() = std::move(temp);
1994
- throw;
1995
- }
2121
+ try {
2122
+ ::new (errptr()) unexpected_type(std::move(rhs.err()));
2123
+ rhs.err().~unexpected_type();
2124
+ ::new (rhs.valptr()) T(std::move(temp));
2125
+ std::swap(this->m_has_val, rhs.m_has_val);
2126
+ } catch (...) {
2127
+ val() = std::move(temp);
2128
+ throw;
2129
+ }
1996
2130
  #else
1997
- ::new (errptr()) unexpected_type(std::move(rhs.err()));
1998
- rhs.err().~unexpected_type();
1999
- ::new (rhs.valptr()) T(std::move(temp));
2000
- std::swap(this->m_has_val, rhs.m_has_val);
2131
+ ::new (errptr()) unexpected_type(std::move(rhs.err()));
2132
+ rhs.err().~unexpected_type();
2133
+ ::new (rhs.valptr()) T(std::move(temp));
2134
+ std::swap(this->m_has_val, rhs.m_has_val);
2001
2135
  #endif
2002
- }
2003
-
2004
- void swap_where_only_one_has_value_and_t_is_not_void(expected& rhs, move_constructing_t_can_throw, t_is_nothrow_move_constructible)
2005
- {
2006
- auto temp = std::move(rhs.err());
2007
- rhs.err().~unexpected_type();
2136
+ }
2137
+
2138
+ void swap_where_only_one_has_value_and_t_is_not_void(expected& rhs,
2139
+ move_constructing_t_can_throw,
2140
+ t_is_nothrow_move_constructible)
2141
+ {
2142
+ auto temp = std::move(rhs.err());
2143
+ rhs.err().~unexpected_type();
2008
2144
  #ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
2009
- try {
2010
- ::new (rhs.valptr()) T(val());
2011
- val().~T();
2012
- ::new (errptr()) unexpected_type(std::move(temp));
2013
- std::swap(this->m_has_val, rhs.m_has_val);
2014
- } catch (...) {
2015
- rhs.err() = std::move(temp);
2016
- throw;
2017
- }
2145
+ try {
2146
+ ::new (rhs.valptr()) T(val());
2147
+ val().~T();
2148
+ ::new (errptr()) unexpected_type(std::move(temp));
2149
+ std::swap(this->m_has_val, rhs.m_has_val);
2150
+ } catch (...) {
2151
+ rhs.err() = std::move(temp);
2152
+ throw;
2153
+ }
2018
2154
  #else
2019
- ::new (rhs.valptr()) T(val());
2020
- val().~T();
2021
- ::new (errptr()) unexpected_type(std::move(temp));
2022
- std::swap(this->m_has_val, rhs.m_has_val);
2155
+ ::new (rhs.valptr()) T(val());
2156
+ val().~T();
2157
+ ::new (errptr()) unexpected_type(std::move(temp));
2158
+ std::swap(this->m_has_val, rhs.m_has_val);
2023
2159
  #endif
2024
- }
2025
-
2026
- public:
2027
- template<class OT = T, class OE = E>
2028
- detail::enable_if_t<detail::is_swappable<OT>::value && detail::is_swappable<OE>::value &&
2029
- (std::is_nothrow_move_constructible<OT>::value || std::is_nothrow_move_constructible<OE>::value)>
2030
- swap(expected& rhs) noexcept(std::is_nothrow_move_constructible<T>::value&& detail::is_nothrow_swappable<T>::value&&
2031
- std::is_nothrow_move_constructible<E>::value&& detail::is_nothrow_swappable<E>::value)
2032
- {
2033
- if (has_value() && rhs.has_value()) {
2034
- swap_where_both_have_value(rhs, typename std::is_void<T>::type{});
2035
- } else if (!has_value() && rhs.has_value()) {
2036
- rhs.swap(*this);
2037
- } else if (has_value()) {
2038
- swap_where_only_one_has_value(rhs, typename std::is_void<T>::type{});
2039
- } else {
2040
- using std::swap;
2041
- swap(err(), rhs.err());
2042
- }
2043
- }
2044
-
2045
- constexpr const T* operator->() const
2046
- {
2047
- return valptr();
2048
- }
2049
- TL_EXPECTED_11_CONSTEXPR T* operator->()
2050
- {
2051
- return valptr();
2052
- }
2053
-
2054
- template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
2055
- constexpr const U& operator*() const&
2056
- {
2057
- return val();
2058
- }
2059
- template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
2060
- TL_EXPECTED_11_CONSTEXPR U& operator*() &
2061
- {
2062
- return val();
2063
- }
2064
- template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
2065
- constexpr const U&& operator*() const&&
2066
- {
2067
- return std::move(val());
2068
- }
2069
- template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
2070
- TL_EXPECTED_11_CONSTEXPR U&& operator*() &&
2071
- {
2072
- return std::move(val());
2073
- }
2074
-
2075
- constexpr bool has_value() const noexcept
2076
- {
2077
- return this->m_has_val;
2078
- }
2079
- constexpr explicit operator bool() const noexcept
2080
- {
2081
- return this->m_has_val;
2082
- }
2083
-
2084
- template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
2085
- TL_EXPECTED_11_CONSTEXPR const U& value() const&
2086
- {
2087
- if (!has_value())
2088
- detail::throw_exception(bad_expected_access<E>(err().value()));
2089
- return val();
2090
- }
2091
- template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
2092
- TL_EXPECTED_11_CONSTEXPR U& value() &
2093
- {
2094
- if (!has_value())
2095
- detail::throw_exception(bad_expected_access<E>(err().value()));
2096
- return val();
2097
- }
2098
- template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
2099
- TL_EXPECTED_11_CONSTEXPR const U&& value() const&&
2100
- {
2101
- if (!has_value())
2102
- detail::throw_exception(bad_expected_access<E>(std::move(err()).value()));
2103
- return std::move(val());
2104
- }
2105
- template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
2106
- TL_EXPECTED_11_CONSTEXPR U&& value() &&
2107
- {
2108
- if (!has_value())
2109
- detail::throw_exception(bad_expected_access<E>(std::move(err()).value()));
2110
- return std::move(val());
2111
- }
2112
-
2113
- constexpr const E& error() const&
2114
- {
2115
- return err().value();
2116
- }
2117
- TL_EXPECTED_11_CONSTEXPR E& error() &
2118
- {
2119
- return err().value();
2120
- }
2121
- constexpr const E&& error() const&&
2122
- {
2123
- return std::move(err().value());
2124
- }
2125
- TL_EXPECTED_11_CONSTEXPR E&& error() &&
2126
- {
2127
- return std::move(err().value());
2128
- }
2129
-
2130
- template<class U>
2131
- constexpr T value_or(U&& v) const&
2132
- {
2133
- static_assert(std::is_copy_constructible<T>::value && std::is_convertible<U&&, T>::value,
2134
- "T must be copy-constructible and convertible to from U&&");
2135
- return bool(*this) ? **this : static_cast<T>(std::forward<U>(v));
2136
- }
2137
- template<class U>
2138
- TL_EXPECTED_11_CONSTEXPR T value_or(U&& v) &&
2139
- {
2140
- static_assert(std::is_move_constructible<T>::value && std::is_convertible<U&&, T>::value,
2141
- "T must be move-constructible and convertible to from U&&");
2142
- return bool(*this) ? std::move(**this) : static_cast<T>(std::forward<U>(v));
2143
- }
2160
+ }
2161
+
2162
+ public:
2163
+ template<class OT = T, class OE = E>
2164
+ detail::enable_if_t<detail::is_swappable<OT>::value && detail::is_swappable<OE>::value &&
2165
+ (std::is_nothrow_move_constructible<OT>::value ||
2166
+ std::is_nothrow_move_constructible<OE>::value)>
2167
+ swap(expected& rhs) noexcept(std::is_nothrow_move_constructible<T>::value &&
2168
+ detail::is_nothrow_swappable<T>::value &&
2169
+ std::is_nothrow_move_constructible<E>::value &&
2170
+ detail::is_nothrow_swappable<E>::value)
2171
+ {
2172
+ if (has_value() && rhs.has_value()) {
2173
+ swap_where_both_have_value(rhs, typename std::is_void<T>::type{});
2174
+ } else if (!has_value() && rhs.has_value()) {
2175
+ rhs.swap(*this);
2176
+ } else if (has_value()) {
2177
+ swap_where_only_one_has_value(rhs, typename std::is_void<T>::type{});
2178
+ } else {
2179
+ using std::swap;
2180
+ swap(err(), rhs.err());
2181
+ }
2182
+ }
2183
+
2184
+ constexpr const T* operator->() const
2185
+ {
2186
+ return valptr();
2187
+ }
2188
+ TL_EXPECTED_11_CONSTEXPR T* operator->()
2189
+ {
2190
+ return valptr();
2191
+ }
2192
+
2193
+ template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
2194
+ constexpr const U& operator*() const&
2195
+ {
2196
+ return val();
2197
+ }
2198
+ template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
2199
+ TL_EXPECTED_11_CONSTEXPR U& operator*() &
2200
+ {
2201
+ return val();
2202
+ }
2203
+ template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
2204
+ constexpr const U&& operator*() const&&
2205
+ {
2206
+ return std::move(val());
2207
+ }
2208
+ template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
2209
+ TL_EXPECTED_11_CONSTEXPR U&& operator*() &&
2210
+ {
2211
+ return std::move(val());
2212
+ }
2213
+
2214
+ constexpr bool has_value() const noexcept
2215
+ {
2216
+ return this->m_has_val;
2217
+ }
2218
+ constexpr explicit operator bool() const noexcept
2219
+ {
2220
+ return this->m_has_val;
2221
+ }
2222
+
2223
+ template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
2224
+ TL_EXPECTED_11_CONSTEXPR const U& value() const&
2225
+ {
2226
+ if (!has_value())
2227
+ detail::throw_exception(bad_expected_access<E>(err().value()));
2228
+ return val();
2229
+ }
2230
+ template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
2231
+ TL_EXPECTED_11_CONSTEXPR U& value() &
2232
+ {
2233
+ if (!has_value())
2234
+ detail::throw_exception(bad_expected_access<E>(err().value()));
2235
+ return val();
2236
+ }
2237
+ template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
2238
+ TL_EXPECTED_11_CONSTEXPR const U&& value() const&&
2239
+ {
2240
+ if (!has_value())
2241
+ detail::throw_exception(bad_expected_access<E>(std::move(err()).value()));
2242
+ return std::move(val());
2243
+ }
2244
+ template<class U = T, detail::enable_if_t<!std::is_void<U>::value>* = nullptr>
2245
+ TL_EXPECTED_11_CONSTEXPR U&& value() &&
2246
+ {
2247
+ if (!has_value())
2248
+ detail::throw_exception(bad_expected_access<E>(std::move(err()).value()));
2249
+ return std::move(val());
2250
+ }
2251
+
2252
+ constexpr const E& error() const&
2253
+ {
2254
+ return err().value();
2255
+ }
2256
+ TL_EXPECTED_11_CONSTEXPR E& error() &
2257
+ {
2258
+ return err().value();
2259
+ }
2260
+ constexpr const E&& error() const&&
2261
+ {
2262
+ return std::move(err().value());
2263
+ }
2264
+ TL_EXPECTED_11_CONSTEXPR E&& error() &&
2265
+ {
2266
+ return std::move(err().value());
2267
+ }
2268
+
2269
+ template<class U>
2270
+ constexpr T value_or(U&& v) const&
2271
+ {
2272
+ static_assert(std::is_copy_constructible<T>::value && std::is_convertible<U&&, T>::value,
2273
+ "T must be copy-constructible and convertible to from U&&");
2274
+ return bool(*this) ? **this : static_cast<T>(std::forward<U>(v));
2275
+ }
2276
+ template<class U>
2277
+ TL_EXPECTED_11_CONSTEXPR T value_or(U&& v) &&
2278
+ {
2279
+ static_assert(std::is_move_constructible<T>::value && std::is_convertible<U&&, T>::value,
2280
+ "T must be move-constructible and convertible to from U&&");
2281
+ return bool(*this) ? std::move(**this) : static_cast<T>(std::forward<U>(v));
2282
+ }
2144
2283
  };
2145
2284
 
2146
2285
  namespace detail
@@ -2160,9 +2299,10 @@ template<class Exp,
2160
2299
  constexpr auto
2161
2300
  and_then_impl(Exp&& exp, F&& f)
2162
2301
  {
2163
- static_assert(detail::is_expected<Ret>::value, "F must return an expected");
2302
+ static_assert(detail::is_expected<Ret>::value, "F must return an expected");
2164
2303
 
2165
- return exp.has_value() ? detail::invoke(std::forward<F>(f), *std::forward<Exp>(exp)) : Ret(unexpect, std::forward<Exp>(exp).error());
2304
+ return exp.has_value() ? detail::invoke(std::forward<F>(f), *std::forward<Exp>(exp))
2305
+ : Ret(unexpect, std::forward<Exp>(exp).error());
2166
2306
  }
2167
2307
 
2168
2308
  template<class Exp,
@@ -2172,9 +2312,10 @@ template<class Exp,
2172
2312
  constexpr auto
2173
2313
  and_then_impl(Exp&& exp, F&& f)
2174
2314
  {
2175
- static_assert(detail::is_expected<Ret>::value, "F must return an expected");
2315
+ static_assert(detail::is_expected<Ret>::value, "F must return an expected");
2176
2316
 
2177
- return exp.has_value() ? detail::invoke(std::forward<F>(f)) : Ret(unexpect, std::forward<Exp>(exp).error());
2317
+ return exp.has_value() ? detail::invoke(std::forward<F>(f))
2318
+ : Ret(unexpect, std::forward<Exp>(exp).error());
2178
2319
  }
2179
2320
  #else
2180
2321
  template<class>
@@ -2186,9 +2327,10 @@ template<class Exp,
2186
2327
  auto
2187
2328
  and_then_impl(Exp&& exp, F&& f) -> Ret
2188
2329
  {
2189
- static_assert(detail::is_expected<Ret>::value, "F must return an expected");
2330
+ static_assert(detail::is_expected<Ret>::value, "F must return an expected");
2190
2331
 
2191
- return exp.has_value() ? detail::invoke(std::forward<F>(f), *std::forward<Exp>(exp)) : Ret(unexpect, std::forward<Exp>(exp).error());
2332
+ return exp.has_value() ? detail::invoke(std::forward<F>(f), *std::forward<Exp>(exp))
2333
+ : Ret(unexpect, std::forward<Exp>(exp).error());
2192
2334
  }
2193
2335
 
2194
2336
  template<class Exp,
@@ -2198,9 +2340,10 @@ template<class Exp,
2198
2340
  constexpr auto
2199
2341
  and_then_impl(Exp&& exp, F&& f) -> Ret
2200
2342
  {
2201
- static_assert(detail::is_expected<Ret>::value, "F must return an expected");
2343
+ static_assert(detail::is_expected<Ret>::value, "F must return an expected");
2202
2344
 
2203
- return exp.has_value() ? detail::invoke(std::forward<F>(f)) : Ret(unexpect, std::forward<Exp>(exp).error());
2345
+ return exp.has_value() ? detail::invoke(std::forward<F>(f))
2346
+ : Ret(unexpect, std::forward<Exp>(exp).error());
2204
2347
  }
2205
2348
  #endif
2206
2349
 
@@ -2213,9 +2356,9 @@ template<class Exp,
2213
2356
  constexpr auto
2214
2357
  expected_map_impl(Exp&& exp, F&& f)
2215
2358
  {
2216
- using result = ret_t<Exp, detail::decay_t<Ret>>;
2217
- return exp.has_value() ? result(detail::invoke(std::forward<F>(f), *std::forward<Exp>(exp)))
2218
- : result(unexpect, std::forward<Exp>(exp).error());
2359
+ using result = ret_t<Exp, detail::decay_t<Ret>>;
2360
+ return exp.has_value() ? result(detail::invoke(std::forward<F>(f), *std::forward<Exp>(exp)))
2361
+ : result(unexpect, std::forward<Exp>(exp).error());
2219
2362
  }
2220
2363
 
2221
2364
  template<class Exp,
@@ -2226,13 +2369,13 @@ template<class Exp,
2226
2369
  auto
2227
2370
  expected_map_impl(Exp&& exp, F&& f)
2228
2371
  {
2229
- using result = expected<void, err_t<Exp>>;
2230
- if (exp.has_value()) {
2231
- detail::invoke(std::forward<F>(f), *std::forward<Exp>(exp));
2232
- return result();
2233
- }
2372
+ using result = expected<void, err_t<Exp>>;
2373
+ if (exp.has_value()) {
2374
+ detail::invoke(std::forward<F>(f), *std::forward<Exp>(exp));
2375
+ return result();
2376
+ }
2234
2377
 
2235
- return result(unexpect, std::forward<Exp>(exp).error());
2378
+ return result(unexpect, std::forward<Exp>(exp).error());
2236
2379
  }
2237
2380
 
2238
2381
  template<class Exp,
@@ -2243,8 +2386,9 @@ template<class Exp,
2243
2386
  constexpr auto
2244
2387
  expected_map_impl(Exp&& exp, F&& f)
2245
2388
  {
2246
- using result = ret_t<Exp, detail::decay_t<Ret>>;
2247
- return exp.has_value() ? result(detail::invoke(std::forward<F>(f))) : result(unexpect, std::forward<Exp>(exp).error());
2389
+ using result = ret_t<Exp, detail::decay_t<Ret>>;
2390
+ return exp.has_value() ? result(detail::invoke(std::forward<F>(f)))
2391
+ : result(unexpect, std::forward<Exp>(exp).error());
2248
2392
  }
2249
2393
 
2250
2394
  template<class Exp,
@@ -2255,13 +2399,13 @@ template<class Exp,
2255
2399
  auto
2256
2400
  expected_map_impl(Exp&& exp, F&& f)
2257
2401
  {
2258
- using result = expected<void, err_t<Exp>>;
2259
- if (exp.has_value()) {
2260
- detail::invoke(std::forward<F>(f));
2261
- return result();
2262
- }
2402
+ using result = expected<void, err_t<Exp>>;
2403
+ if (exp.has_value()) {
2404
+ detail::invoke(std::forward<F>(f));
2405
+ return result();
2406
+ }
2263
2407
 
2264
- return result(unexpect, std::forward<Exp>(exp).error());
2408
+ return result(unexpect, std::forward<Exp>(exp).error());
2265
2409
  }
2266
2410
  #else
2267
2411
  template<class Exp,
@@ -2273,10 +2417,10 @@ template<class Exp,
2273
2417
  constexpr auto
2274
2418
  expected_map_impl(Exp&& exp, F&& f) -> ret_t<Exp, detail::decay_t<Ret>>
2275
2419
  {
2276
- using result = ret_t<Exp, detail::decay_t<Ret>>;
2420
+ using result = ret_t<Exp, detail::decay_t<Ret>>;
2277
2421
 
2278
- return exp.has_value() ? result(detail::invoke(std::forward<F>(f), *std::forward<Exp>(exp)))
2279
- : result(unexpect, std::forward<Exp>(exp).error());
2422
+ return exp.has_value() ? result(detail::invoke(std::forward<F>(f), *std::forward<Exp>(exp)))
2423
+ : result(unexpect, std::forward<Exp>(exp).error());
2280
2424
  }
2281
2425
 
2282
2426
  template<class Exp,
@@ -2288,12 +2432,12 @@ template<class Exp,
2288
2432
  auto
2289
2433
  expected_map_impl(Exp&& exp, F&& f) -> expected<void, err_t<Exp>>
2290
2434
  {
2291
- if (exp.has_value()) {
2292
- detail::invoke(std::forward<F>(f), *std::forward<Exp>(exp));
2293
- return {};
2294
- }
2435
+ if (exp.has_value()) {
2436
+ detail::invoke(std::forward<F>(f), *std::forward<Exp>(exp));
2437
+ return {};
2438
+ }
2295
2439
 
2296
- return unexpected<err_t<Exp>>(std::forward<Exp>(exp).error());
2440
+ return unexpected<err_t<Exp>>(std::forward<Exp>(exp).error());
2297
2441
  }
2298
2442
 
2299
2443
  template<class Exp,
@@ -2305,9 +2449,10 @@ template<class Exp,
2305
2449
  constexpr auto
2306
2450
  expected_map_impl(Exp&& exp, F&& f) -> ret_t<Exp, detail::decay_t<Ret>>
2307
2451
  {
2308
- using result = ret_t<Exp, detail::decay_t<Ret>>;
2452
+ using result = ret_t<Exp, detail::decay_t<Ret>>;
2309
2453
 
2310
- return exp.has_value() ? result(detail::invoke(std::forward<F>(f))) : result(unexpect, std::forward<Exp>(exp).error());
2454
+ return exp.has_value() ? result(detail::invoke(std::forward<F>(f)))
2455
+ : result(unexpect, std::forward<Exp>(exp).error());
2311
2456
  }
2312
2457
 
2313
2458
  template<class Exp,
@@ -2319,16 +2464,17 @@ template<class Exp,
2319
2464
  auto
2320
2465
  expected_map_impl(Exp&& exp, F&& f) -> expected<void, err_t<Exp>>
2321
2466
  {
2322
- if (exp.has_value()) {
2323
- detail::invoke(std::forward<F>(f));
2324
- return {};
2325
- }
2467
+ if (exp.has_value()) {
2468
+ detail::invoke(std::forward<F>(f));
2469
+ return {};
2470
+ }
2326
2471
 
2327
- return unexpected<err_t<Exp>>(std::forward<Exp>(exp).error());
2472
+ return unexpected<err_t<Exp>>(std::forward<Exp>(exp).error());
2328
2473
  }
2329
2474
  #endif
2330
2475
 
2331
- #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55)
2476
+ #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && !defined(TL_EXPECTED_GCC54) && \
2477
+ !defined(TL_EXPECTED_GCC55)
2332
2478
  template<class Exp,
2333
2479
  class F,
2334
2480
  detail::enable_if_t<!std::is_void<exp_t<Exp>>::value>* = nullptr,
@@ -2337,9 +2483,10 @@ template<class Exp,
2337
2483
  constexpr auto
2338
2484
  map_error_impl(Exp&& exp, F&& f)
2339
2485
  {
2340
- using result = expected<exp_t<Exp>, detail::decay_t<Ret>>;
2341
- return exp.has_value() ? result(*std::forward<Exp>(exp))
2342
- : result(unexpect, detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error()));
2486
+ using result = expected<exp_t<Exp>, detail::decay_t<Ret>>;
2487
+ return exp.has_value()
2488
+ ? result(*std::forward<Exp>(exp))
2489
+ : result(unexpect, detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error()));
2343
2490
  }
2344
2491
  template<class Exp,
2345
2492
  class F,
@@ -2349,13 +2496,13 @@ template<class Exp,
2349
2496
  auto
2350
2497
  map_error_impl(Exp&& exp, F&& f)
2351
2498
  {
2352
- using result = expected<exp_t<Exp>, monostate>;
2353
- if (exp.has_value()) {
2354
- return result(*std::forward<Exp>(exp));
2355
- }
2499
+ using result = expected<exp_t<Exp>, monostate>;
2500
+ if (exp.has_value()) {
2501
+ return result(*std::forward<Exp>(exp));
2502
+ }
2356
2503
 
2357
- detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error());
2358
- return result(unexpect, monostate{});
2504
+ detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error());
2505
+ return result(unexpect, monostate{});
2359
2506
  }
2360
2507
  template<class Exp,
2361
2508
  class F,
@@ -2365,8 +2512,10 @@ template<class Exp,
2365
2512
  constexpr auto
2366
2513
  map_error_impl(Exp&& exp, F&& f)
2367
2514
  {
2368
- using result = expected<exp_t<Exp>, detail::decay_t<Ret>>;
2369
- return exp.has_value() ? result() : result(unexpect, detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error()));
2515
+ using result = expected<exp_t<Exp>, detail::decay_t<Ret>>;
2516
+ return exp.has_value()
2517
+ ? result()
2518
+ : result(unexpect, detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error()));
2370
2519
  }
2371
2520
  template<class Exp,
2372
2521
  class F,
@@ -2376,13 +2525,13 @@ template<class Exp,
2376
2525
  auto
2377
2526
  map_error_impl(Exp&& exp, F&& f)
2378
2527
  {
2379
- using result = expected<exp_t<Exp>, monostate>;
2380
- if (exp.has_value()) {
2381
- return result();
2382
- }
2528
+ using result = expected<exp_t<Exp>, monostate>;
2529
+ if (exp.has_value()) {
2530
+ return result();
2531
+ }
2383
2532
 
2384
- detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error());
2385
- return result(unexpect, monostate{});
2533
+ detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error());
2534
+ return result(unexpect, monostate{});
2386
2535
  }
2387
2536
  #else
2388
2537
  template<class Exp,
@@ -2393,10 +2542,11 @@ template<class Exp,
2393
2542
  constexpr auto
2394
2543
  map_error_impl(Exp&& exp, F&& f) -> expected<exp_t<Exp>, detail::decay_t<Ret>>
2395
2544
  {
2396
- using result = expected<exp_t<Exp>, detail::decay_t<Ret>>;
2545
+ using result = expected<exp_t<Exp>, detail::decay_t<Ret>>;
2397
2546
 
2398
- return exp.has_value() ? result(*std::forward<Exp>(exp))
2399
- : result(unexpect, detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error()));
2547
+ return exp.has_value()
2548
+ ? result(*std::forward<Exp>(exp))
2549
+ : result(unexpect, detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error()));
2400
2550
  }
2401
2551
 
2402
2552
  template<class Exp,
@@ -2407,13 +2557,13 @@ template<class Exp,
2407
2557
  auto
2408
2558
  map_error_impl(Exp&& exp, F&& f) -> expected<exp_t<Exp>, monostate>
2409
2559
  {
2410
- using result = expected<exp_t<Exp>, monostate>;
2411
- if (exp.has_value()) {
2412
- return result(*std::forward<Exp>(exp));
2413
- }
2560
+ using result = expected<exp_t<Exp>, monostate>;
2561
+ if (exp.has_value()) {
2562
+ return result(*std::forward<Exp>(exp));
2563
+ }
2414
2564
 
2415
- detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error());
2416
- return result(unexpect, monostate{});
2565
+ detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error());
2566
+ return result(unexpect, monostate{});
2417
2567
  }
2418
2568
 
2419
2569
  template<class Exp,
@@ -2424,9 +2574,11 @@ template<class Exp,
2424
2574
  constexpr auto
2425
2575
  map_error_impl(Exp&& exp, F&& f) -> expected<exp_t<Exp>, detail::decay_t<Ret>>
2426
2576
  {
2427
- using result = expected<exp_t<Exp>, detail::decay_t<Ret>>;
2577
+ using result = expected<exp_t<Exp>, detail::decay_t<Ret>>;
2428
2578
 
2429
- return exp.has_value() ? result() : result(unexpect, detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error()));
2579
+ return exp.has_value()
2580
+ ? result()
2581
+ : result(unexpect, detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error()));
2430
2582
  }
2431
2583
 
2432
2584
  template<class Exp,
@@ -2437,13 +2589,13 @@ template<class Exp,
2437
2589
  auto
2438
2590
  map_error_impl(Exp&& exp, F&& f) -> expected<exp_t<Exp>, monostate>
2439
2591
  {
2440
- using result = expected<exp_t<Exp>, monostate>;
2441
- if (exp.has_value()) {
2442
- return result();
2443
- }
2592
+ using result = expected<exp_t<Exp>, monostate>;
2593
+ if (exp.has_value()) {
2594
+ return result();
2595
+ }
2444
2596
 
2445
- detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error());
2446
- return result(unexpect, monostate{});
2597
+ detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error());
2598
+ return result(unexpect, monostate{});
2447
2599
  }
2448
2600
  #endif
2449
2601
 
@@ -2455,8 +2607,9 @@ template<class Exp,
2455
2607
  constexpr auto
2456
2608
  or_else_impl(Exp&& exp, F&& f)
2457
2609
  {
2458
- static_assert(detail::is_expected<Ret>::value, "F must return an expected");
2459
- return exp.has_value() ? std::forward<Exp>(exp) : detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error());
2610
+ static_assert(detail::is_expected<Ret>::value, "F must return an expected");
2611
+ return exp.has_value() ? std::forward<Exp>(exp)
2612
+ : detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error());
2460
2613
  }
2461
2614
 
2462
2615
  template<class Exp,
@@ -2466,8 +2619,9 @@ template<class Exp,
2466
2619
  detail::decay_t<Exp>
2467
2620
  or_else_impl(Exp&& exp, F&& f)
2468
2621
  {
2469
- return exp.has_value() ? std::forward<Exp>(exp)
2470
- : (detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error()), std::forward<Exp>(exp));
2622
+ return exp.has_value() ? std::forward<Exp>(exp)
2623
+ : (detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error()),
2624
+ std::forward<Exp>(exp));
2471
2625
  }
2472
2626
  #else
2473
2627
  template<class Exp,
@@ -2477,8 +2631,9 @@ template<class Exp,
2477
2631
  auto
2478
2632
  or_else_impl(Exp&& exp, F&& f) -> Ret
2479
2633
  {
2480
- static_assert(detail::is_expected<Ret>::value, "F must return an expected");
2481
- return exp.has_value() ? std::forward<Exp>(exp) : detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error());
2634
+ static_assert(detail::is_expected<Ret>::value, "F must return an expected");
2635
+ return exp.has_value() ? std::forward<Exp>(exp)
2636
+ : detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error());
2482
2637
  }
2483
2638
 
2484
2639
  template<class Exp,
@@ -2488,8 +2643,9 @@ template<class Exp,
2488
2643
  detail::decay_t<Exp>
2489
2644
  or_else_impl(Exp&& exp, F&& f)
2490
2645
  {
2491
- return exp.has_value() ? std::forward<Exp>(exp)
2492
- : (detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error()), std::forward<Exp>(exp));
2646
+ return exp.has_value() ? std::forward<Exp>(exp)
2647
+ : (detail::invoke(std::forward<F>(f), std::forward<Exp>(exp).error()),
2648
+ std::forward<Exp>(exp));
2493
2649
  }
2494
2650
  #endif
2495
2651
  } // namespace detail
@@ -2498,73 +2654,79 @@ template<class T, class E, class U, class F>
2498
2654
  constexpr bool
2499
2655
  operator==(const expected<T, E>& lhs, const expected<U, F>& rhs)
2500
2656
  {
2501
- return (lhs.has_value() != rhs.has_value()) ? false : (!lhs.has_value() ? lhs.error() == rhs.error() : *lhs == *rhs);
2657
+ return (lhs.has_value() != rhs.has_value())
2658
+ ? false
2659
+ : (!lhs.has_value() ? lhs.error() == rhs.error() : *lhs == *rhs);
2502
2660
  }
2503
2661
  template<class T, class E, class U, class F>
2504
2662
  constexpr bool
2505
2663
  operator!=(const expected<T, E>& lhs, const expected<U, F>& rhs)
2506
2664
  {
2507
- return (lhs.has_value() != rhs.has_value()) ? true : (!lhs.has_value() ? lhs.error() != rhs.error() : *lhs != *rhs);
2665
+ return (lhs.has_value() != rhs.has_value())
2666
+ ? true
2667
+ : (!lhs.has_value() ? lhs.error() != rhs.error() : *lhs != *rhs);
2508
2668
  }
2509
2669
 
2510
2670
  template<class T, class E, class U>
2511
2671
  constexpr bool
2512
2672
  operator==(const expected<T, E>& x, const U& v)
2513
2673
  {
2514
- return x.has_value() ? *x == v : false;
2674
+ return x.has_value() ? *x == v : false;
2515
2675
  }
2516
2676
  template<class T, class E, class U>
2517
2677
  constexpr bool
2518
2678
  operator==(const U& v, const expected<T, E>& x)
2519
2679
  {
2520
- return x.has_value() ? *x == v : false;
2680
+ return x.has_value() ? *x == v : false;
2521
2681
  }
2522
2682
  template<class T, class E, class U>
2523
2683
  constexpr bool
2524
2684
  operator!=(const expected<T, E>& x, const U& v)
2525
2685
  {
2526
- return x.has_value() ? *x != v : true;
2686
+ return x.has_value() ? *x != v : true;
2527
2687
  }
2528
2688
  template<class T, class E, class U>
2529
2689
  constexpr bool
2530
2690
  operator!=(const U& v, const expected<T, E>& x)
2531
2691
  {
2532
- return x.has_value() ? *x != v : true;
2692
+ return x.has_value() ? *x != v : true;
2533
2693
  }
2534
2694
 
2535
2695
  template<class T, class E>
2536
2696
  constexpr bool
2537
2697
  operator==(const expected<T, E>& x, const unexpected<E>& e)
2538
2698
  {
2539
- return x.has_value() ? false : x.error() == e.value();
2699
+ return x.has_value() ? false : x.error() == e.value();
2540
2700
  }
2541
2701
  template<class T, class E>
2542
2702
  constexpr bool
2543
2703
  operator==(const unexpected<E>& e, const expected<T, E>& x)
2544
2704
  {
2545
- return x.has_value() ? false : x.error() == e.value();
2705
+ return x.has_value() ? false : x.error() == e.value();
2546
2706
  }
2547
2707
  template<class T, class E>
2548
2708
  constexpr bool
2549
2709
  operator!=(const expected<T, E>& x, const unexpected<E>& e)
2550
2710
  {
2551
- return x.has_value() ? true : x.error() != e.value();
2711
+ return x.has_value() ? true : x.error() != e.value();
2552
2712
  }
2553
2713
  template<class T, class E>
2554
2714
  constexpr bool
2555
2715
  operator!=(const unexpected<E>& e, const expected<T, E>& x)
2556
2716
  {
2557
- return x.has_value() ? true : x.error() != e.value();
2717
+ return x.has_value() ? true : x.error() != e.value();
2558
2718
  }
2559
2719
 
2560
- template<class T,
2561
- class E,
2562
- detail::enable_if_t<(std::is_void<T>::value || std::is_move_constructible<T>::value) && detail::is_swappable<T>::value &&
2563
- std::is_move_constructible<E>::value && detail::is_swappable<E>::value>* = nullptr>
2720
+ template<
2721
+ class T,
2722
+ class E,
2723
+ detail::enable_if_t<(std::is_void<T>::value || std::is_move_constructible<T>::value) &&
2724
+ detail::is_swappable<T>::value && std::is_move_constructible<E>::value &&
2725
+ detail::is_swappable<E>::value>* = nullptr>
2564
2726
  void
2565
2727
  swap(expected<T, E>& lhs, expected<T, E>& rhs) noexcept(noexcept(lhs.swap(rhs)))
2566
2728
  {
2567
- lhs.swap(rhs);
2729
+ lhs.swap(rhs);
2568
2730
  }
2569
2731
  } // namespace tl
2570
2732