couchbase 3.5.1 → 3.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/ext/0001-fix-build-for-mingw-w64-ucrt-x86_64-toolchain.patch +40 -0
- data/ext/CMakeLists.txt +22 -2
- data/ext/cache/extconf_include.rb +3 -3
- data/ext/cache/mozilla-ca-bundle.crt +19 -32
- data/ext/cache/mozilla-ca-bundle.sha256 +1 -1
- data/ext/couchbase/CMakeLists.txt +16 -9
- data/ext/couchbase/cmake/0001-fix-build-for-mingw-w64-ucrt-x86_64-toolchain.patch +3 -4
- data/ext/couchbase/cmake/CompilerWarnings.cmake +2 -1
- data/ext/couchbase/cmake/Packaging.cmake +41 -0
- data/ext/couchbase/cmake/Sanitizers.cmake +1 -0
- data/ext/couchbase/cmake/VersionInfo.cmake +5 -5
- data/ext/couchbase/cmake/build_version.hxx.in +1 -0
- data/ext/couchbase/cmake/couchbase-cxx-client.pc.in +10 -0
- data/ext/couchbase/cmake/test_boringssl.cxx +1 -1
- data/ext/couchbase/cmake/test_openssl.cxx +1 -1
- data/ext/couchbase/core/agent.cxx +353 -304
- data/ext/couchbase/core/agent.hxx +94 -76
- data/ext/couchbase/core/agent_config.cxx +9 -8
- data/ext/couchbase/core/agent_config.hxx +7 -7
- data/ext/couchbase/core/agent_group.cxx +132 -120
- data/ext/couchbase/core/agent_group.hxx +26 -22
- data/ext/couchbase/core/agent_group_config.cxx +8 -7
- data/ext/couchbase/core/agent_group_config.hxx +6 -6
- data/ext/couchbase/core/agent_unit_test_api.hxx +6 -6
- data/ext/couchbase/core/analytics_query_options.cxx +21 -21
- data/ext/couchbase/core/analytics_query_options.hxx +19 -18
- data/ext/couchbase/core/analytics_scan_consistency.hxx +2 -2
- data/ext/couchbase/core/bucket.cxx +848 -776
- data/ext/couchbase/core/bucket.hxx +151 -139
- data/ext/couchbase/core/capella_ca.hxx +20 -19
- data/ext/couchbase/core/cluster.cxx +1240 -927
- data/ext/couchbase/core/cluster.hxx +254 -167
- data/ext/couchbase/core/cluster_agent.cxx +7 -7
- data/ext/couchbase/core/cluster_agent.hxx +4 -4
- data/ext/couchbase/core/cluster_agent_config.cxx +8 -7
- data/ext/couchbase/core/cluster_agent_config.hxx +6 -6
- data/ext/couchbase/core/cluster_options.cxx +17 -17
- data/ext/couchbase/core/cluster_options.hxx +50 -47
- data/ext/couchbase/core/cluster_state.hxx +3 -3
- data/ext/couchbase/core/collection_id_cache_entry.hxx +5 -4
- data/ext/couchbase/core/collections_component.cxx +372 -329
- data/ext/couchbase/core/collections_component.hxx +17 -13
- data/ext/couchbase/core/collections_component_unit_test_api.hxx +6 -6
- data/ext/couchbase/core/collections_options.hxx +29 -27
- data/ext/couchbase/core/config_listener.hxx +3 -3
- data/ext/couchbase/core/config_profile.hxx +3 -3
- data/ext/couchbase/core/config_profiles.cxx +31 -31
- data/ext/couchbase/core/config_profiles.hxx +19 -19
- data/ext/couchbase/core/core_sdk_shim.cxx +2 -1
- data/ext/couchbase/core/core_sdk_shim.hxx +2 -2
- data/ext/couchbase/core/crud_component.cxx +310 -276
- data/ext/couchbase/core/crud_component.hxx +21 -15
- data/ext/couchbase/core/crud_options.hxx +361 -354
- data/ext/couchbase/core/crypto/cbcrypto.cc +732 -627
- data/ext/couchbase/core/crypto/cbcrypto.h +12 -3
- data/ext/couchbase/core/design_document_namespace.hxx +2 -2
- data/ext/couchbase/core/design_document_namespace_fmt.hxx +18 -18
- data/ext/couchbase/core/diagnostics.hxx +44 -44
- data/ext/couchbase/core/diagnostics_fmt.hxx +76 -76
- data/ext/couchbase/core/diagnostics_json.hxx +61 -60
- data/ext/couchbase/core/diagntostics_options.hxx +14 -14
- data/ext/couchbase/core/dispatcher.cxx +4 -3
- data/ext/couchbase/core/dispatcher.hxx +8 -7
- data/ext/couchbase/core/document_id.cxx +37 -34
- data/ext/couchbase/core/document_id.hxx +87 -86
- data/ext/couchbase/core/document_id_fmt.hxx +10 -10
- data/ext/couchbase/core/durability_options.hxx +50 -49
- data/ext/couchbase/core/error_context/analytics.hxx +18 -18
- data/ext/couchbase/core/error_context/analytics_json.hxx +115 -0
- data/ext/couchbase/core/error_context/base_error_context.hxx +184 -0
- data/ext/couchbase/core/error_context/http.hxx +14 -14
- data/ext/couchbase/core/error_context/http_json.hxx +90 -0
- data/ext/couchbase/core/error_context/internal_tof_metadata_json.hxx +36 -0
- data/ext/couchbase/core/error_context/key_value.cxx +27 -27
- data/ext/couchbase/core/error_context/key_value.hxx +41 -38
- data/ext/couchbase/core/error_context/key_value_error_context.hxx +235 -0
- data/ext/couchbase/core/error_context/key_value_error_map_attribute.hxx +142 -0
- data/ext/couchbase/core/error_context/key_value_error_map_info.hxx +139 -0
- data/ext/couchbase/core/error_context/key_value_extended_error_info.hxx +86 -0
- data/ext/couchbase/core/error_context/key_value_json.hxx +83 -0
- data/ext/couchbase/core/error_context/key_value_status_code.hxx +109 -0
- data/ext/couchbase/core/error_context/query.hxx +18 -18
- data/ext/couchbase/core/error_context/query_error_context.hxx +150 -0
- data/ext/couchbase/core/error_context/query_json.hxx +114 -0
- data/ext/couchbase/core/error_context/query_public_json.hxx +84 -0
- data/ext/couchbase/core/error_context/search.hxx +17 -17
- data/ext/couchbase/core/error_context/search_json.hxx +101 -0
- data/ext/couchbase/core/error_context/subdocument_error_context.hxx +147 -0
- data/ext/couchbase/core/error_context/subdocument_json.hxx +48 -0
- data/ext/couchbase/{couchbase → core/error_context}/transaction_error_context.hxx +22 -22
- data/ext/couchbase/core/error_context/transaction_op_error_context.hxx +79 -0
- data/ext/couchbase/core/error_context/view.hxx +17 -17
- data/ext/couchbase/core/fmt/key_value_error_map_attribute.hxx +100 -0
- data/ext/couchbase/{couchbase → core}/fmt/key_value_extended_error_info.hxx +20 -20
- data/ext/couchbase/core/fmt/key_value_status_code.hxx +269 -0
- data/ext/couchbase/core/free_form_http_request.cxx +26 -26
- data/ext/couchbase/core/free_form_http_request.hxx +34 -33
- data/ext/couchbase/core/impl/analytics.cxx +111 -131
- data/ext/couchbase/core/impl/analytics.hxx +5 -7
- data/ext/couchbase/core/impl/analytics_error_category.cxx +29 -28
- data/ext/couchbase/core/impl/analytics_index_manager.cxx +615 -516
- data/ext/couchbase/core/impl/best_effort_retry_strategy.cxx +53 -50
- data/ext/couchbase/core/impl/binary_collection.cxx +346 -285
- data/ext/couchbase/core/impl/boolean_field_query.cxx +10 -10
- data/ext/couchbase/core/impl/boolean_query.cxx +27 -27
- data/ext/couchbase/core/impl/bootstrap_state_listener.hxx +6 -6
- data/ext/couchbase/core/impl/bucket.cxx +39 -34
- data/ext/couchbase/core/impl/bucket_manager.cxx +354 -313
- data/ext/couchbase/core/impl/cluster.cxx +430 -325
- data/ext/couchbase/core/impl/collection.cxx +1033 -1187
- data/ext/couchbase/core/impl/collection_manager.cxx +201 -170
- data/ext/couchbase/core/impl/common_error_category.cxx +58 -55
- data/ext/couchbase/core/impl/configuration_profiles_registry.cxx +46 -32
- data/ext/couchbase/core/impl/conjunction_query.cxx +17 -17
- data/ext/couchbase/core/impl/date_range.cxx +24 -20
- data/ext/couchbase/core/impl/date_range_facet.cxx +22 -22
- data/ext/couchbase/core/impl/date_range_facet_result.cxx +6 -6
- data/ext/couchbase/core/impl/date_range_query.cxx +50 -48
- data/ext/couchbase/core/impl/diagnostics.cxx +211 -198
- data/ext/couchbase/core/impl/diagnostics.hxx +7 -6
- data/ext/couchbase/core/impl/disjunction_query.cxx +18 -17
- data/ext/couchbase/core/impl/dns_srv_tracker.cxx +92 -75
- data/ext/couchbase/core/impl/dns_srv_tracker.hxx +24 -20
- data/ext/couchbase/core/impl/doc_id_query.cxx +9 -9
- data/ext/couchbase/core/impl/encoded_search_facet.hxx +2 -2
- data/ext/couchbase/core/impl/encoded_search_query.hxx +2 -2
- data/ext/couchbase/core/impl/encoded_search_sort.hxx +2 -2
- data/ext/couchbase/core/impl/error.cxx +171 -0
- data/ext/couchbase/core/impl/error.hxx +64 -0
- data/ext/couchbase/core/impl/error_context.cxx +56 -0
- data/ext/couchbase/core/impl/expiry.cxx +66 -53
- data/ext/couchbase/core/impl/fail_fast_retry_strategy.cxx +5 -4
- data/ext/couchbase/core/impl/field_level_encryption_error_category.cxx +30 -28
- data/ext/couchbase/core/impl/geo_bounding_box_query.cxx +17 -17
- data/ext/couchbase/core/impl/geo_distance_query.cxx +14 -14
- data/ext/couchbase/core/impl/geo_polygon_query.cxx +17 -17
- data/ext/couchbase/core/impl/get_all_replicas.hxx +26 -22
- data/ext/couchbase/core/impl/get_any_replica.hxx +25 -23
- data/ext/couchbase/core/impl/get_replica.cxx +18 -15
- data/ext/couchbase/core/impl/get_replica.hxx +23 -18
- data/ext/couchbase/core/impl/internal_date_range_facet_result.cxx +16 -14
- data/ext/couchbase/core/impl/internal_date_range_facet_result.hxx +16 -15
- data/ext/couchbase/core/impl/internal_error_context.cxx +79 -0
- data/ext/couchbase/core/impl/internal_error_context.hxx +52 -0
- data/ext/couchbase/core/impl/internal_numeric_range_facet_result.cxx +18 -15
- data/ext/couchbase/core/impl/internal_numeric_range_facet_result.hxx +16 -15
- data/ext/couchbase/core/impl/internal_scan_result.hxx +7 -7
- data/ext/couchbase/core/impl/internal_search_error_context.cxx +25 -22
- data/ext/couchbase/core/impl/internal_search_error_context.hxx +32 -31
- data/ext/couchbase/core/impl/internal_search_meta_data.cxx +15 -13
- data/ext/couchbase/core/impl/internal_search_meta_data.hxx +10 -9
- data/ext/couchbase/core/impl/internal_search_result.cxx +30 -22
- data/ext/couchbase/core/impl/internal_search_result.hxx +10 -9
- data/ext/couchbase/core/impl/internal_search_row.cxx +10 -10
- data/ext/couchbase/core/impl/internal_search_row.hxx +16 -16
- data/ext/couchbase/core/impl/internal_search_row_location.hxx +2 -2
- data/ext/couchbase/core/impl/internal_search_row_locations.cxx +68 -65
- data/ext/couchbase/core/impl/internal_search_row_locations.hxx +16 -13
- data/ext/couchbase/core/impl/internal_term_facet_result.cxx +16 -14
- data/ext/couchbase/core/impl/internal_term_facet_result.hxx +15 -15
- data/ext/couchbase/core/impl/key_value_error_category.cxx +73 -72
- data/ext/couchbase/core/impl/key_value_error_context.cxx +65 -65
- data/ext/couchbase/core/impl/logger.cxx +91 -0
- data/ext/couchbase/core/impl/lookup_in_all_replicas.hxx +32 -29
- data/ext/couchbase/core/impl/lookup_in_any_replica.hxx +33 -29
- data/ext/couchbase/core/impl/lookup_in_replica.cxx +75 -68
- data/ext/couchbase/core/impl/lookup_in_replica.hxx +30 -26
- data/ext/couchbase/core/impl/management_error_category.cxx +41 -40
- data/ext/couchbase/core/impl/match_all_query.cxx +6 -6
- data/ext/couchbase/core/impl/match_none_query.cxx +6 -6
- data/ext/couchbase/core/impl/match_phrase_query.cxx +13 -13
- data/ext/couchbase/core/impl/match_query.cxx +28 -28
- data/ext/couchbase/core/impl/network_error_category.cxx +39 -38
- data/ext/couchbase/core/impl/numeric_range.cxx +6 -6
- data/ext/couchbase/core/impl/numeric_range_facet.cxx +22 -22
- data/ext/couchbase/core/impl/numeric_range_facet_result.cxx +6 -6
- data/ext/couchbase/core/impl/numeric_range_query.cxx +22 -22
- data/ext/couchbase/core/impl/observe_poll.cxx +294 -277
- data/ext/couchbase/core/impl/observe_poll.hxx +1 -1
- data/ext/couchbase/core/impl/observe_seqno.cxx +21 -18
- data/ext/couchbase/core/impl/observe_seqno.hxx +31 -26
- data/ext/couchbase/core/impl/phrase_query.cxx +10 -10
- data/ext/couchbase/core/impl/prefix_query.cxx +10 -10
- data/ext/couchbase/core/impl/query.cxx +163 -154
- data/ext/couchbase/core/impl/query.hxx +6 -7
- data/ext/couchbase/core/impl/query_error_category.cxx +22 -21
- data/ext/couchbase/core/impl/query_error_context.cxx +45 -45
- data/ext/couchbase/core/impl/query_index_manager.cxx +488 -408
- data/ext/couchbase/core/impl/query_string_query.cxx +7 -7
- data/ext/couchbase/core/impl/regexp_query.cxx +10 -10
- data/ext/couchbase/core/impl/replica_utils.cxx +66 -0
- data/ext/couchbase/core/impl/replica_utils.hxx +48 -0
- data/ext/couchbase/core/impl/retry_action.cxx +3 -3
- data/ext/couchbase/core/impl/retry_reason.cxx +129 -56
- data/ext/couchbase/core/impl/retry_reason.hxx +28 -0
- data/ext/couchbase/core/impl/scan_result.cxx +53 -49
- data/ext/couchbase/core/impl/scope.cxx +103 -94
- data/ext/couchbase/core/impl/search.cxx +139 -130
- data/ext/couchbase/core/impl/search.hxx +4 -4
- data/ext/couchbase/core/impl/search_error_category.cxx +18 -17
- data/ext/couchbase/core/impl/search_index_manager.cxx +492 -390
- data/ext/couchbase/core/impl/search_meta_data.cxx +3 -3
- data/ext/couchbase/core/impl/search_request.cxx +78 -78
- data/ext/couchbase/core/impl/search_result.cxx +5 -5
- data/ext/couchbase/core/impl/search_row.cxx +7 -7
- data/ext/couchbase/core/impl/search_row_location.cxx +9 -8
- data/ext/couchbase/core/impl/search_row_locations.cxx +8 -7
- data/ext/couchbase/core/impl/search_sort_field.cxx +53 -53
- data/ext/couchbase/core/impl/search_sort_geo_distance.cxx +49 -48
- data/ext/couchbase/core/impl/search_sort_id.cxx +10 -10
- data/ext/couchbase/core/impl/search_sort_score.cxx +10 -10
- data/ext/couchbase/core/impl/streaming_json_lexer_error_category.cxx +70 -68
- data/ext/couchbase/core/impl/subdoc/array_add_unique.cxx +6 -6
- data/ext/couchbase/core/impl/subdoc/array_append.cxx +6 -6
- data/ext/couchbase/core/impl/subdoc/array_insert.cxx +6 -6
- data/ext/couchbase/core/impl/subdoc/array_prepend.cxx +6 -6
- data/ext/couchbase/core/impl/subdoc/command.hxx +5 -5
- data/ext/couchbase/core/impl/subdoc/command_bundle.hxx +11 -11
- data/ext/couchbase/core/impl/subdoc/count.cxx +6 -6
- data/ext/couchbase/core/impl/subdoc/counter.cxx +6 -6
- data/ext/couchbase/core/impl/subdoc/exists.cxx +6 -6
- data/ext/couchbase/core/impl/subdoc/get.cxx +6 -6
- data/ext/couchbase/core/impl/subdoc/insert.cxx +6 -6
- data/ext/couchbase/core/impl/subdoc/join_values.cxx +25 -25
- data/ext/couchbase/core/impl/subdoc/lookup_in_macro.cxx +61 -60
- data/ext/couchbase/core/impl/subdoc/lookup_in_specs.cxx +9 -9
- data/ext/couchbase/core/impl/subdoc/mutate_in_macro.cxx +48 -39
- data/ext/couchbase/core/impl/subdoc/mutate_in_specs.cxx +9 -9
- data/ext/couchbase/core/impl/subdoc/opcode.hxx +16 -16
- data/ext/couchbase/core/impl/subdoc/path_flags.hxx +40 -17
- data/ext/couchbase/core/impl/subdoc/remove.cxx +6 -6
- data/ext/couchbase/core/impl/subdoc/replace.cxx +6 -6
- data/ext/couchbase/core/impl/subdoc/upsert.cxx +6 -6
- data/ext/couchbase/core/impl/term_facet.cxx +8 -8
- data/ext/couchbase/core/impl/term_facet_result.cxx +6 -6
- data/ext/couchbase/core/impl/term_query.cxx +25 -25
- data/ext/couchbase/core/impl/term_range_query.cxx +22 -22
- data/ext/couchbase/core/impl/transaction_error_category.cxx +21 -20
- data/ext/couchbase/core/impl/transaction_get_result.cxx +41 -30
- data/ext/couchbase/core/impl/transaction_op_error_category.cxx +55 -56
- data/ext/couchbase/core/impl/vector_query.cxx +15 -10
- data/ext/couchbase/core/impl/vector_search.cxx +9 -9
- data/ext/couchbase/core/impl/view_error_category.cxx +17 -16
- data/ext/couchbase/core/impl/wildcard_query.cxx +10 -10
- data/ext/couchbase/core/impl/with_legacy_durability.hxx +30 -29
- data/ext/couchbase/core/io/dns_client.cxx +257 -232
- data/ext/couchbase/core/io/dns_client.hxx +19 -18
- data/ext/couchbase/core/io/dns_codec.hxx +156 -154
- data/ext/couchbase/core/io/dns_config.cxx +114 -109
- data/ext/couchbase/core/io/dns_config.hxx +15 -13
- data/ext/couchbase/core/io/dns_message.hxx +365 -342
- data/ext/couchbase/core/io/http_command.hxx +155 -134
- data/ext/couchbase/core/io/http_context.hxx +5 -5
- data/ext/couchbase/core/io/http_message.hxx +75 -71
- data/ext/couchbase/core/io/http_parser.cxx +70 -67
- data/ext/couchbase/core/io/http_parser.hxx +18 -18
- data/ext/couchbase/core/io/http_session.hxx +620 -520
- data/ext/couchbase/core/io/http_session_manager.hxx +406 -315
- data/ext/couchbase/core/io/http_traits.hxx +7 -0
- data/ext/couchbase/core/io/ip_protocol.hxx +3 -3
- data/ext/couchbase/core/io/mcbp_command.hxx +298 -278
- data/ext/couchbase/core/io/mcbp_context.hxx +7 -6
- data/ext/couchbase/core/io/mcbp_message.cxx +8 -8
- data/ext/couchbase/core/io/mcbp_message.hxx +19 -19
- data/ext/couchbase/core/io/mcbp_parser.cxx +60 -51
- data/ext/couchbase/core/io/mcbp_parser.hxx +21 -17
- data/ext/couchbase/core/io/mcbp_session.cxx +1769 -1616
- data/ext/couchbase/core/io/mcbp_session.hxx +63 -57
- data/ext/couchbase/core/io/query_cache.hxx +34 -34
- data/ext/couchbase/core/io/retry_context.hxx +45 -45
- data/ext/couchbase/core/io/retry_orchestrator.hxx +52 -42
- data/ext/couchbase/core/io/streams.hxx +210 -193
- data/ext/couchbase/core/json_string.hxx +47 -47
- data/ext/couchbase/core/key_value_config.cxx +8 -8
- data/ext/couchbase/core/key_value_config.hxx +12 -11
- data/ext/couchbase/core/logger/configuration.hxx +35 -35
- data/ext/couchbase/core/logger/custom_rotating_file_sink.cxx +73 -72
- data/ext/couchbase/core/logger/custom_rotating_file_sink.hxx +20 -18
- data/ext/couchbase/core/logger/level.hxx +9 -1
- data/ext/couchbase/core/logger/logger.cxx +279 -252
- data/ext/couchbase/core/logger/logger.hxx +110 -58
- data/ext/couchbase/core/management/analytics_dataset.hxx +4 -4
- data/ext/couchbase/core/management/analytics_index.hxx +4 -4
- data/ext/couchbase/core/management/analytics_link_azure_blob_external.cxx +35 -33
- data/ext/couchbase/core/management/analytics_link_azure_blob_external.hxx +36 -35
- data/ext/couchbase/core/management/analytics_link_azure_blob_external_json.hxx +24 -20
- data/ext/couchbase/core/management/analytics_link_couchbase_remote.cxx +66 -65
- data/ext/couchbase/core/management/analytics_link_couchbase_remote.hxx +77 -70
- data/ext/couchbase/core/management/analytics_link_couchbase_remote_json.hxx +38 -32
- data/ext/couchbase/core/management/analytics_link_s3_external.cxx +26 -25
- data/ext/couchbase/core/management/analytics_link_s3_external.hxx +30 -30
- data/ext/couchbase/core/management/analytics_link_s3_external_json.hxx +18 -16
- data/ext/couchbase/core/management/bucket_settings.hxx +109 -91
- data/ext/couchbase/core/management/bucket_settings_json.hxx +112 -94
- data/ext/couchbase/core/management/design_document.hxx +9 -9
- data/ext/couchbase/core/management/eventing_function.hxx +124 -121
- data/ext/couchbase/core/management/eventing_function_json.hxx +228 -184
- data/ext/couchbase/core/management/eventing_status.hxx +41 -41
- data/ext/couchbase/core/management/eventing_status_json.hxx +53 -45
- data/ext/couchbase/core/management/rbac.hxx +33 -28
- data/ext/couchbase/core/management/rbac_fmt.hxx +21 -21
- data/ext/couchbase/core/management/rbac_json.hxx +132 -125
- data/ext/couchbase/core/management/search_index.cxx +79 -0
- data/ext/couchbase/core/management/search_index.hxx +11 -10
- data/ext/couchbase/core/management/search_index_json.hxx +27 -26
- data/ext/couchbase/core/mcbp/barrier_frame.hxx +4 -3
- data/ext/couchbase/core/mcbp/big_endian.cxx +22 -22
- data/ext/couchbase/core/mcbp/buffer_writer.cxx +22 -19
- data/ext/couchbase/core/mcbp/buffer_writer.hxx +9 -9
- data/ext/couchbase/core/mcbp/codec.cxx +419 -397
- data/ext/couchbase/core/mcbp/codec.hxx +14 -12
- data/ext/couchbase/core/mcbp/command_code.cxx +48 -48
- data/ext/couchbase/core/mcbp/completion_token.hxx +33 -33
- data/ext/couchbase/core/mcbp/datatype.hxx +3 -3
- data/ext/couchbase/core/mcbp/durability_level.hxx +8 -7
- data/ext/couchbase/core/mcbp/durability_level_frame.hxx +3 -2
- data/ext/couchbase/core/mcbp/durability_timeout_frame.hxx +4 -3
- data/ext/couchbase/core/mcbp/open_tracing_frame.hxx +3 -2
- data/ext/couchbase/core/mcbp/operation_consumer.cxx +3 -3
- data/ext/couchbase/core/mcbp/operation_consumer.hxx +9 -9
- data/ext/couchbase/core/mcbp/operation_queue.cxx +76 -70
- data/ext/couchbase/core/mcbp/operation_queue.hxx +18 -17
- data/ext/couchbase/core/mcbp/packet.cxx +65 -51
- data/ext/couchbase/core/mcbp/packet.hxx +25 -25
- data/ext/couchbase/core/mcbp/preserve_expiry_frame.hxx +4 -2
- data/ext/couchbase/core/mcbp/queue_callback.hxx +3 -2
- data/ext/couchbase/core/mcbp/queue_request.cxx +65 -62
- data/ext/couchbase/core/mcbp/queue_request.hxx +54 -52
- data/ext/couchbase/core/mcbp/queue_request_connection_info.hxx +3 -3
- data/ext/couchbase/core/mcbp/queue_response.hxx +7 -7
- data/ext/couchbase/core/mcbp/read_units_frame.hxx +3 -2
- data/ext/couchbase/core/mcbp/server_duration.cxx +7 -7
- data/ext/couchbase/core/mcbp/server_duration_frame.hxx +3 -2
- data/ext/couchbase/core/mcbp/stream_id_frame.hxx +3 -2
- data/ext/couchbase/core/mcbp/unsupported_frame.hxx +4 -3
- data/ext/couchbase/core/mcbp/user_impersonation_frame.hxx +1 -1
- data/ext/couchbase/core/mcbp/write_units_frame.hxx +3 -2
- data/ext/couchbase/core/meta/features.hxx +58 -0
- data/ext/couchbase/core/meta/version.cxx +255 -204
- data/ext/couchbase/core/meta/version.hxx +31 -20
- data/ext/couchbase/core/metrics/logging_meter.cxx +160 -154
- data/ext/couchbase/core/metrics/logging_meter.hxx +16 -15
- data/ext/couchbase/core/metrics/logging_meter_options.hxx +1 -1
- data/ext/couchbase/core/metrics/noop_meter.hxx +14 -13
- data/ext/couchbase/core/mozilla_ca_bundle.hxx +2 -2
- data/ext/couchbase/core/n1ql_query_options.cxx +31 -31
- data/ext/couchbase/core/n1ql_query_options.hxx +22 -21
- data/ext/couchbase/core/operation_map.hxx +3 -3
- data/ext/couchbase/core/operations/document_analytics.cxx +187 -176
- data/ext/couchbase/core/operations/document_analytics.hxx +79 -71
- data/ext/couchbase/core/operations/document_append.cxx +18 -15
- data/ext/couchbase/core/operations/document_append.hxx +18 -16
- data/ext/couchbase/core/operations/document_decrement.cxx +26 -23
- data/ext/couchbase/core/operations/document_decrement.hxx +24 -20
- data/ext/couchbase/core/operations/document_exists.cxx +23 -21
- data/ext/couchbase/core/operations/document_exists.hxx +25 -23
- data/ext/couchbase/core/operations/document_get.cxx +17 -15
- data/ext/couchbase/core/operations/document_get.hxx +17 -15
- data/ext/couchbase/core/operations/document_get_all_replicas.hxx +121 -92
- data/ext/couchbase/core/operations/document_get_and_lock.cxx +19 -16
- data/ext/couchbase/core/operations/document_get_and_lock.hxx +21 -17
- data/ext/couchbase/core/operations/document_get_and_touch.cxx +19 -16
- data/ext/couchbase/core/operations/document_get_and_touch.hxx +22 -18
- data/ext/couchbase/core/operations/document_get_any_replica.hxx +111 -82
- data/ext/couchbase/core/operations/document_get_projected.cxx +193 -184
- data/ext/couchbase/core/operations/document_get_projected.hxx +25 -21
- data/ext/couchbase/core/operations/document_increment.cxx +26 -23
- data/ext/couchbase/core/operations/document_increment.hxx +24 -20
- data/ext/couchbase/core/operations/document_insert.cxx +23 -20
- data/ext/couchbase/core/operations/document_insert.hxx +20 -18
- data/ext/couchbase/core/operations/document_lookup_in.cxx +80 -67
- data/ext/couchbase/core/operations/document_lookup_in.hxx +31 -27
- data/ext/couchbase/core/operations/document_lookup_in_all_replicas.hxx +187 -149
- data/ext/couchbase/core/operations/document_lookup_in_any_replica.hxx +190 -145
- data/ext/couchbase/core/operations/document_mutate_in.cxx +98 -80
- data/ext/couchbase/core/operations/document_mutate_in.hxx +38 -33
- data/ext/couchbase/core/operations/document_prepend.cxx +18 -15
- data/ext/couchbase/core/operations/document_prepend.hxx +18 -16
- data/ext/couchbase/core/operations/document_query.cxx +367 -356
- data/ext/couchbase/core/operations/document_query.hxx +83 -79
- data/ext/couchbase/core/operations/document_remove.cxx +18 -15
- data/ext/couchbase/core/operations/document_remove.hxx +18 -16
- data/ext/couchbase/core/operations/document_replace.cxx +27 -24
- data/ext/couchbase/core/operations/document_replace.hxx +22 -20
- data/ext/couchbase/core/operations/document_search.cxx +322 -308
- data/ext/couchbase/core/operations/document_search.hxx +125 -121
- data/ext/couchbase/core/operations/document_touch.cxx +16 -14
- data/ext/couchbase/core/operations/document_touch.hxx +19 -17
- data/ext/couchbase/core/operations/document_unlock.cxx +16 -14
- data/ext/couchbase/core/operations/document_unlock.hxx +19 -17
- data/ext/couchbase/core/operations/document_upsert.cxx +26 -23
- data/ext/couchbase/core/operations/document_upsert.hxx +21 -19
- data/ext/couchbase/core/operations/document_view.cxx +169 -159
- data/ext/couchbase/core/operations/document_view.hxx +68 -65
- data/ext/couchbase/core/operations/http_noop.cxx +38 -35
- data/ext/couchbase/core/operations/http_noop.hxx +12 -10
- data/ext/couchbase/core/operations/management/analytics_dataset_create.cxx +58 -56
- data/ext/couchbase/core/operations/management/analytics_dataset_create.hxx +20 -17
- data/ext/couchbase/core/operations/management/analytics_dataset_drop.cxx +49 -44
- data/ext/couchbase/core/operations/management/analytics_dataset_drop.hxx +18 -15
- data/ext/couchbase/core/operations/management/analytics_dataset_get_all.cxx +46 -43
- data/ext/couchbase/core/operations/management/analytics_dataset_get_all.hxx +16 -13
- data/ext/couchbase/core/operations/management/analytics_dataverse_create.cxx +48 -43
- data/ext/couchbase/core/operations/management/analytics_dataverse_create.hxx +17 -14
- data/ext/couchbase/core/operations/management/analytics_dataverse_drop.cxx +48 -43
- data/ext/couchbase/core/operations/management/analytics_dataverse_drop.hxx +17 -14
- data/ext/couchbase/core/operations/management/analytics_get_pending_mutations.cxx +38 -35
- data/ext/couchbase/core/operations/management/analytics_get_pending_mutations.hxx +16 -14
- data/ext/couchbase/core/operations/management/analytics_index_create.cxx +68 -66
- data/ext/couchbase/core/operations/management/analytics_index_create.hxx +20 -17
- data/ext/couchbase/core/operations/management/analytics_index_drop.cxx +56 -51
- data/ext/couchbase/core/operations/management/analytics_index_drop.hxx +19 -16
- data/ext/couchbase/core/operations/management/analytics_index_get_all.cxx +44 -42
- data/ext/couchbase/core/operations/management/analytics_index_get_all.hxx +16 -13
- data/ext/couchbase/core/operations/management/analytics_link_connect.cxx +49 -43
- data/ext/couchbase/core/operations/management/analytics_link_connect.hxx +23 -20
- data/ext/couchbase/core/operations/management/analytics_link_create.cxx +52 -51
- data/ext/couchbase/core/operations/management/analytics_link_create.hxx +33 -30
- data/ext/couchbase/core/operations/management/analytics_link_disconnect.cxx +46 -42
- data/ext/couchbase/core/operations/management/analytics_link_disconnect.hxx +22 -19
- data/ext/couchbase/core/operations/management/analytics_link_drop.cxx +70 -67
- data/ext/couchbase/core/operations/management/analytics_link_drop.hxx +22 -19
- data/ext/couchbase/core/operations/management/analytics_link_get_all.cxx +92 -85
- data/ext/couchbase/core/operations/management/analytics_link_get_all.hxx +27 -24
- data/ext/couchbase/core/operations/management/analytics_link_replace.cxx +52 -51
- data/ext/couchbase/core/operations/management/analytics_link_replace.hxx +33 -30
- data/ext/couchbase/core/operations/management/analytics_link_utils.hxx +6 -4
- data/ext/couchbase/core/operations/management/analytics_problem.hxx +2 -2
- data/ext/couchbase/core/operations/management/bucket_create.cxx +158 -149
- data/ext/couchbase/core/operations/management/bucket_create.hxx +14 -12
- data/ext/couchbase/core/operations/management/bucket_describe.cxx +118 -42
- data/ext/couchbase/core/operations/management/bucket_describe.hxx +47 -22
- data/ext/couchbase/core/operations/management/bucket_drop.cxx +19 -18
- data/ext/couchbase/core/operations/management/bucket_drop.hxx +13 -11
- data/ext/couchbase/core/operations/management/bucket_flush.cxx +25 -24
- data/ext/couchbase/core/operations/management/bucket_flush.hxx +13 -11
- data/ext/couchbase/core/operations/management/bucket_get.cxx +24 -22
- data/ext/couchbase/core/operations/management/bucket_get.hxx +14 -12
- data/ext/couchbase/core/operations/management/bucket_get_all.cxx +25 -23
- data/ext/couchbase/core/operations/management/bucket_get_all.hxx +13 -11
- data/ext/couchbase/core/operations/management/bucket_update.cxx +112 -107
- data/ext/couchbase/core/operations/management/bucket_update.hxx +15 -13
- data/ext/couchbase/core/operations/management/change_password.cxx +22 -20
- data/ext/couchbase/core/operations/management/change_password.hxx +13 -11
- data/ext/couchbase/core/operations/management/cluster_describe.cxx +52 -50
- data/ext/couchbase/core/operations/management/cluster_describe.hxx +31 -29
- data/ext/couchbase/core/operations/management/cluster_developer_preview_enable.cxx +14 -12
- data/ext/couchbase/core/operations/management/cluster_developer_preview_enable.hxx +13 -11
- data/ext/couchbase/core/operations/management/collection_create.cxx +48 -46
- data/ext/couchbase/core/operations/management/collection_create.hxx +19 -16
- data/ext/couchbase/core/operations/management/collection_drop.cxx +37 -35
- data/ext/couchbase/core/operations/management/collection_drop.hxx +16 -14
- data/ext/couchbase/core/operations/management/collection_update.cxx +49 -47
- data/ext/couchbase/core/operations/management/collection_update.hxx +19 -16
- data/ext/couchbase/core/operations/management/collections_manifest_get.cxx +11 -9
- data/ext/couchbase/core/operations/management/collections_manifest_get.hxx +17 -13
- data/ext/couchbase/core/operations/management/error_utils.cxx +210 -198
- data/ext/couchbase/core/operations/management/error_utils.hxx +3 -1
- data/ext/couchbase/core/operations/management/eventing_deploy_function.cxx +30 -28
- data/ext/couchbase/core/operations/management/eventing_deploy_function.hxx +17 -14
- data/ext/couchbase/core/operations/management/eventing_drop_function.cxx +31 -29
- data/ext/couchbase/core/operations/management/eventing_drop_function.hxx +17 -14
- data/ext/couchbase/core/operations/management/eventing_get_all_functions.cxx +49 -43
- data/ext/couchbase/core/operations/management/eventing_get_all_functions.hxx +17 -14
- data/ext/couchbase/core/operations/management/eventing_get_function.cxx +29 -27
- data/ext/couchbase/core/operations/management/eventing_get_function.hxx +18 -15
- data/ext/couchbase/core/operations/management/eventing_get_status.cxx +45 -39
- data/ext/couchbase/core/operations/management/eventing_get_status.hxx +17 -14
- data/ext/couchbase/core/operations/management/eventing_pause_function.cxx +30 -28
- data/ext/couchbase/core/operations/management/eventing_pause_function.hxx +17 -14
- data/ext/couchbase/core/operations/management/eventing_problem.hxx +3 -3
- data/ext/couchbase/core/operations/management/eventing_resume_function.cxx +30 -28
- data/ext/couchbase/core/operations/management/eventing_resume_function.hxx +17 -14
- data/ext/couchbase/core/operations/management/eventing_undeploy_function.cxx +30 -28
- data/ext/couchbase/core/operations/management/eventing_undeploy_function.hxx +17 -14
- data/ext/couchbase/core/operations/management/eventing_upsert_function.cxx +328 -318
- data/ext/couchbase/core/operations/management/eventing_upsert_function.hxx +17 -14
- data/ext/couchbase/core/operations/management/freeform.cxx +23 -22
- data/ext/couchbase/core/operations/management/freeform.hxx +19 -17
- data/ext/couchbase/core/operations/management/group_drop.cxx +18 -17
- data/ext/couchbase/core/operations/management/group_drop.hxx +13 -11
- data/ext/couchbase/core/operations/management/group_get.cxx +25 -23
- data/ext/couchbase/core/operations/management/group_get.hxx +14 -12
- data/ext/couchbase/core/operations/management/group_get_all.cxx +23 -22
- data/ext/couchbase/core/operations/management/group_get_all.hxx +13 -11
- data/ext/couchbase/core/operations/management/group_upsert.cxx +58 -55
- data/ext/couchbase/core/operations/management/group_upsert.hxx +14 -12
- data/ext/couchbase/core/operations/management/query_index_build.cxx +53 -48
- data/ext/couchbase/core/operations/management/query_index_build.hxx +25 -22
- data/ext/couchbase/core/operations/management/query_index_build_deferred.hxx +75 -67
- data/ext/couchbase/core/operations/management/query_index_create.cxx +128 -122
- data/ext/couchbase/core/operations/management/query_index_create.hxx +31 -28
- data/ext/couchbase/core/operations/management/query_index_drop.cxx +95 -93
- data/ext/couchbase/core/operations/management/query_index_drop.hxx +26 -24
- data/ext/couchbase/core/operations/management/query_index_get_all.cxx +97 -93
- data/ext/couchbase/core/operations/management/query_index_get_all.hxx +24 -21
- data/ext/couchbase/core/operations/management/query_index_get_all_deferred.cxx +66 -62
- data/ext/couchbase/core/operations/management/query_index_get_all_deferred.hxx +24 -22
- data/ext/couchbase/core/operations/management/role_get_all.cxx +24 -22
- data/ext/couchbase/core/operations/management/role_get_all.hxx +13 -11
- data/ext/couchbase/core/operations/management/scope_create.cxx +38 -36
- data/ext/couchbase/core/operations/management/scope_create.hxx +15 -13
- data/ext/couchbase/core/operations/management/scope_drop.cxx +33 -32
- data/ext/couchbase/core/operations/management/scope_drop.hxx +15 -13
- data/ext/couchbase/core/operations/management/scope_get_all.cxx +27 -25
- data/ext/couchbase/core/operations/management/scope_get_all.hxx +14 -12
- data/ext/couchbase/core/operations/management/search_get_stats.cxx +12 -10
- data/ext/couchbase/core/operations/management/search_get_stats.hxx +13 -11
- data/ext/couchbase/core/operations/management/search_index_analyze_document.cxx +72 -67
- data/ext/couchbase/core/operations/management/search_index_analyze_document.hxx +20 -18
- data/ext/couchbase/core/operations/management/search_index_control_ingest.cxx +62 -59
- data/ext/couchbase/core/operations/management/search_index_control_ingest.hxx +19 -16
- data/ext/couchbase/core/operations/management/search_index_control_plan_freeze.cxx +62 -59
- data/ext/couchbase/core/operations/management/search_index_control_plan_freeze.hxx +19 -17
- data/ext/couchbase/core/operations/management/search_index_control_query.cxx +62 -59
- data/ext/couchbase/core/operations/management/search_index_control_query.hxx +19 -16
- data/ext/couchbase/core/operations/management/search_index_drop.cxx +58 -55
- data/ext/couchbase/core/operations/management/search_index_drop.hxx +18 -15
- data/ext/couchbase/core/operations/management/search_index_get.cxx +59 -56
- data/ext/couchbase/core/operations/management/search_index_get.hxx +18 -16
- data/ext/couchbase/core/operations/management/search_index_get_all.cxx +51 -46
- data/ext/couchbase/core/operations/management/search_index_get_all.hxx +18 -15
- data/ext/couchbase/core/operations/management/search_index_get_documents_count.cxx +66 -61
- data/ext/couchbase/core/operations/management/search_index_get_documents_count.hxx +19 -17
- data/ext/couchbase/core/operations/management/search_index_get_stats.cxx +38 -36
- data/ext/couchbase/core/operations/management/search_index_get_stats.hxx +17 -14
- data/ext/couchbase/core/operations/management/search_index_upsert.cxx +98 -95
- data/ext/couchbase/core/operations/management/search_index_upsert.hxx +20 -17
- data/ext/couchbase/core/operations/management/user_drop.cxx +18 -17
- data/ext/couchbase/core/operations/management/user_drop.hxx +16 -12
- data/ext/couchbase/core/operations/management/user_get.cxx +25 -23
- data/ext/couchbase/core/operations/management/user_get.hxx +17 -13
- data/ext/couchbase/core/operations/management/user_get_all.cxx +24 -22
- data/ext/couchbase/core/operations/management/user_get_all.hxx +16 -12
- data/ext/couchbase/core/operations/management/user_upsert.cxx +63 -60
- data/ext/couchbase/core/operations/management/user_upsert.hxx +17 -13
- data/ext/couchbase/core/operations/management/view_index_drop.cxx +16 -12
- data/ext/couchbase/core/operations/management/view_index_drop.hxx +15 -13
- data/ext/couchbase/core/operations/management/view_index_get.cxx +40 -35
- data/ext/couchbase/core/operations/management/view_index_get.hxx +16 -14
- data/ext/couchbase/core/operations/management/view_index_get_all.cxx +73 -69
- data/ext/couchbase/core/operations/management/view_index_get_all.hxx +16 -13
- data/ext/couchbase/core/operations/management/view_index_upsert.cxx +39 -35
- data/ext/couchbase/core/operations/management/view_index_upsert.hxx +15 -12
- data/ext/couchbase/core/origin.cxx +259 -249
- data/ext/couchbase/core/origin.hxx +55 -49
- data/ext/couchbase/core/pending_operation.hxx +3 -3
- data/ext/couchbase/core/ping_collector.hxx +3 -3
- data/ext/couchbase/core/ping_options.hxx +30 -30
- data/ext/couchbase/core/ping_reporter.hxx +3 -3
- data/ext/couchbase/core/platform/backtrace.c +100 -91
- data/ext/couchbase/core/platform/base64.cc +135 -134
- data/ext/couchbase/core/platform/dirutils.cc +66 -63
- data/ext/couchbase/core/platform/random.cc +43 -42
- data/ext/couchbase/core/platform/random.h +4 -4
- data/ext/couchbase/core/platform/string_hex.cc +42 -40
- data/ext/couchbase/core/platform/terminate_handler.cc +54 -52
- data/ext/couchbase/core/platform/uuid.cc +47 -47
- data/ext/couchbase/core/protocol/client_opcode.hxx +336 -327
- data/ext/couchbase/core/protocol/client_opcode_fmt.hxx +291 -291
- data/ext/couchbase/core/protocol/client_request.cxx +13 -10
- data/ext/couchbase/core/protocol/client_request.hxx +133 -130
- data/ext/couchbase/core/protocol/client_response.cxx +40 -40
- data/ext/couchbase/core/protocol/client_response.hxx +153 -150
- data/ext/couchbase/core/protocol/cmd_append.cxx +24 -23
- data/ext/couchbase/core/protocol/cmd_append.hxx +65 -65
- data/ext/couchbase/core/protocol/cmd_cluster_map_change_notification.cxx +25 -21
- data/ext/couchbase/core/protocol/cmd_cluster_map_change_notification.hxx +33 -25
- data/ext/couchbase/core/protocol/cmd_decrement.cxx +38 -38
- data/ext/couchbase/core/protocol/cmd_decrement.hxx +87 -87
- data/ext/couchbase/core/protocol/cmd_get.cxx +17 -17
- data/ext/couchbase/core/protocol/cmd_get.hxx +59 -59
- data/ext/couchbase/core/protocol/cmd_get_and_lock.cxx +20 -20
- data/ext/couchbase/core/protocol/cmd_get_and_lock.hxx +72 -72
- data/ext/couchbase/core/protocol/cmd_get_and_touch.cxx +20 -20
- data/ext/couchbase/core/protocol/cmd_get_and_touch.hxx +72 -72
- data/ext/couchbase/core/protocol/cmd_get_cluster_config.cxx +46 -39
- data/ext/couchbase/core/protocol/cmd_get_cluster_config.hxx +57 -49
- data/ext/couchbase/core/protocol/cmd_get_collection_id.cxx +17 -17
- data/ext/couchbase/core/protocol/cmd_get_collection_id.hxx +59 -59
- data/ext/couchbase/core/protocol/cmd_get_collections_manifest.cxx +16 -14
- data/ext/couchbase/core/protocol/cmd_get_collections_manifest.hxx +39 -39
- data/ext/couchbase/core/protocol/cmd_get_error_map.cxx +18 -17
- data/ext/couchbase/core/protocol/cmd_get_error_map.hxx +62 -62
- data/ext/couchbase/core/protocol/cmd_get_meta.cxx +24 -23
- data/ext/couchbase/core/protocol/cmd_get_meta.hxx +81 -79
- data/ext/couchbase/core/protocol/cmd_get_replica.cxx +23 -23
- data/ext/couchbase/core/protocol/cmd_get_replica.hxx +44 -44
- data/ext/couchbase/core/protocol/cmd_hello.cxx +28 -27
- data/ext/couchbase/core/protocol/cmd_hello.hxx +106 -105
- data/ext/couchbase/core/protocol/cmd_increment.cxx +38 -38
- data/ext/couchbase/core/protocol/cmd_increment.hxx +87 -87
- data/ext/couchbase/core/protocol/cmd_info.hxx +3 -3
- data/ext/couchbase/core/protocol/cmd_insert.cxx +27 -27
- data/ext/couchbase/core/protocol/cmd_insert.hxx +81 -81
- data/ext/couchbase/core/protocol/cmd_lookup_in.cxx +54 -51
- data/ext/couchbase/core/protocol/cmd_lookup_in.hxx +90 -90
- data/ext/couchbase/core/protocol/cmd_lookup_in_replica.cxx +54 -51
- data/ext/couchbase/core/protocol/cmd_lookup_in_replica.hxx +88 -88
- data/ext/couchbase/core/protocol/cmd_mutate_in.cxx +105 -97
- data/ext/couchbase/core/protocol/cmd_mutate_in.hxx +161 -153
- data/ext/couchbase/core/protocol/cmd_noop.cxx +4 -4
- data/ext/couchbase/core/protocol/cmd_noop.hxx +32 -32
- data/ext/couchbase/core/protocol/cmd_observe_seqno.cxx +36 -34
- data/ext/couchbase/core/protocol/cmd_observe_seqno.hxx +89 -89
- data/ext/couchbase/core/protocol/cmd_prepend.cxx +22 -22
- data/ext/couchbase/core/protocol/cmd_prepend.hxx +63 -63
- data/ext/couchbase/core/protocol/cmd_remove.cxx +23 -23
- data/ext/couchbase/core/protocol/cmd_remove.hxx +54 -54
- data/ext/couchbase/core/protocol/cmd_replace.cxx +28 -28
- data/ext/couchbase/core/protocol/cmd_replace.hxx +88 -88
- data/ext/couchbase/core/protocol/cmd_sasl_auth.cxx +17 -15
- data/ext/couchbase/core/protocol/cmd_sasl_auth.hxx +56 -56
- data/ext/couchbase/core/protocol/cmd_sasl_list_mechs.cxx +24 -19
- data/ext/couchbase/core/protocol/cmd_sasl_list_mechs.hxx +39 -39
- data/ext/couchbase/core/protocol/cmd_sasl_step.cxx +17 -15
- data/ext/couchbase/core/protocol/cmd_sasl_step.hxx +56 -56
- data/ext/couchbase/core/protocol/cmd_select_bucket.cxx +6 -6
- data/ext/couchbase/core/protocol/cmd_select_bucket.hxx +36 -36
- data/ext/couchbase/core/protocol/cmd_touch.cxx +8 -8
- data/ext/couchbase/core/protocol/cmd_touch.hxx +38 -38
- data/ext/couchbase/core/protocol/cmd_unlock.cxx +5 -5
- data/ext/couchbase/core/protocol/cmd_unlock.hxx +36 -36
- data/ext/couchbase/core/protocol/cmd_upsert.cxx +28 -28
- data/ext/couchbase/core/protocol/cmd_upsert.hxx +83 -83
- data/ext/couchbase/core/protocol/datatype.hxx +19 -18
- data/ext/couchbase/core/protocol/frame_info_id.hxx +108 -103
- data/ext/couchbase/core/protocol/frame_info_id_fmt.hxx +45 -45
- data/ext/couchbase/core/protocol/frame_info_utils.cxx +24 -21
- data/ext/couchbase/core/protocol/frame_info_utils.hxx +3 -1
- data/ext/couchbase/core/protocol/hello_feature.hxx +211 -175
- data/ext/couchbase/core/protocol/hello_feature_fmt.hxx +93 -90
- data/ext/couchbase/core/protocol/magic.hxx +24 -24
- data/ext/couchbase/core/protocol/magic_fmt.hxx +30 -30
- data/ext/couchbase/core/protocol/server_opcode.hxx +11 -11
- data/ext/couchbase/core/protocol/server_opcode_fmt.hxx +18 -18
- data/ext/couchbase/core/protocol/server_request.hxx +90 -86
- data/ext/couchbase/core/protocol/status.cxx +138 -138
- data/ext/couchbase/core/protocol/status.hxx +86 -86
- data/ext/couchbase/core/query_context.hxx +44 -43
- data/ext/couchbase/core/range_scan_load_balancer.cxx +51 -50
- data/ext/couchbase/core/range_scan_load_balancer.hxx +26 -25
- data/ext/couchbase/core/range_scan_options.cxx +2 -2
- data/ext/couchbase/core/range_scan_options.hxx +62 -59
- data/ext/couchbase/core/range_scan_orchestrator.cxx +515 -470
- data/ext/couchbase/core/range_scan_orchestrator.hxx +23 -18
- data/ext/couchbase/core/range_scan_orchestrator_options.hxx +10 -10
- data/ext/couchbase/core/resource_units.hxx +2 -2
- data/ext/couchbase/core/response_handler.hxx +8 -8
- data/ext/couchbase/core/retry_orchestrator.cxx +27 -19
- data/ext/couchbase/core/retry_orchestrator.hxx +3 -2
- data/ext/couchbase/core/sasl/client.cc +22 -18
- data/ext/couchbase/core/sasl/client.h +66 -62
- data/ext/couchbase/core/sasl/context.cc +4 -4
- data/ext/couchbase/core/sasl/context.h +19 -19
- data/ext/couchbase/core/sasl/error.h +12 -1
- data/ext/couchbase/core/sasl/error_fmt.h +42 -42
- data/ext/couchbase/core/sasl/mechanism.cc +13 -10
- data/ext/couchbase/core/sasl/mechanism.h +8 -3
- data/ext/couchbase/core/sasl/plain/plain.cc +8 -8
- data/ext/couchbase/core/sasl/plain/plain.h +25 -24
- data/ext/couchbase/core/sasl/scram-sha/scram-sha.cc +225 -218
- data/ext/couchbase/core/sasl/scram-sha/scram-sha.h +133 -115
- data/ext/couchbase/core/sasl/scram-sha/stringutils.cc +20 -20
- data/ext/couchbase/core/scan_result.cxx +38 -38
- data/ext/couchbase/core/scan_result.hxx +16 -16
- data/ext/couchbase/core/search_highlight_style.hxx +4 -1
- data/ext/couchbase/core/search_query_options.cxx +21 -21
- data/ext/couchbase/core/search_query_options.hxx +19 -18
- data/ext/couchbase/core/search_scan_consistency.hxx +3 -1
- data/ext/couchbase/core/seed_config.cxx +10 -7
- data/ext/couchbase/core/seed_config.hxx +8 -8
- data/ext/couchbase/core/service_type.hxx +7 -7
- data/ext/couchbase/core/service_type_fmt.hxx +33 -33
- data/ext/couchbase/core/stats_options.hxx +13 -13
- data/ext/couchbase/core/subdoc_options.hxx +60 -58
- data/ext/couchbase/core/tls_verify_mode.hxx +2 -2
- data/ext/couchbase/core/topology/capabilities.hxx +83 -83
- data/ext/couchbase/core/topology/capabilities_fmt.hxx +111 -111
- data/ext/couchbase/core/topology/collections_manifest.hxx +14 -14
- data/ext/couchbase/core/topology/collections_manifest_fmt.hxx +23 -21
- data/ext/couchbase/core/topology/collections_manifest_json.hxx +26 -25
- data/ext/couchbase/core/topology/configuration.cxx +213 -192
- data/ext/couchbase/core/topology/configuration.hxx +104 -91
- data/ext/couchbase/core/topology/configuration_fmt.hxx +131 -128
- data/ext/couchbase/core/topology/configuration_json.hxx +276 -242
- data/ext/couchbase/core/topology/error_map.hxx +5 -5
- data/ext/couchbase/core/topology/error_map_json.hxx +65 -60
- data/ext/couchbase/core/tracing/constants.hxx +153 -153
- data/ext/couchbase/core/tracing/noop_tracer.hxx +29 -28
- data/ext/couchbase/core/tracing/threshold_logging_options.hxx +30 -30
- data/ext/couchbase/core/tracing/threshold_logging_tracer.cxx +354 -344
- data/ext/couchbase/core/tracing/threshold_logging_tracer.hxx +12 -12
- data/ext/couchbase/core/transactions/active_transaction_record.cxx +153 -33
- data/ext/couchbase/core/transactions/active_transaction_record.hxx +30 -118
- data/ext/couchbase/core/transactions/async_attempt_context.cxx +8 -2
- data/ext/couchbase/core/transactions/async_attempt_context.hxx +163 -127
- data/ext/couchbase/core/transactions/atr_cleanup_entry.cxx +358 -334
- data/ext/couchbase/core/transactions/atr_ids.cxx +270 -185
- data/ext/couchbase/core/transactions/atr_ids.hxx +4 -4
- data/ext/couchbase/core/transactions/attempt_context.cxx +9 -5
- data/ext/couchbase/core/transactions/attempt_context.hxx +194 -154
- data/ext/couchbase/core/transactions/attempt_context_impl.cxx +3278 -2159
- data/ext/couchbase/core/transactions/attempt_context_impl.hxx +446 -573
- data/ext/couchbase/core/transactions/attempt_context_testing_hooks.cxx +15 -10
- data/ext/couchbase/core/transactions/attempt_context_testing_hooks.hxx +58 -49
- data/ext/couchbase/core/transactions/attempt_state.hxx +72 -72
- data/ext/couchbase/core/transactions/binary.cxx +3 -3
- data/ext/couchbase/core/transactions/cleanup_testing_hooks.cxx +2 -2
- data/ext/couchbase/core/transactions/cleanup_testing_hooks.hxx +28 -24
- data/ext/couchbase/core/transactions/document_metadata.hxx +68 -68
- data/ext/couchbase/core/transactions/durability_level.hxx +53 -53
- data/ext/couchbase/core/transactions/error_class.hxx +12 -12
- data/ext/couchbase/core/transactions/error_list.hxx +22 -22
- data/ext/couchbase/core/transactions/exceptions.cxx +167 -114
- data/ext/couchbase/core/transactions/exceptions.hxx +170 -139
- data/ext/couchbase/core/transactions/exceptions_fmt.hxx +105 -0
- data/ext/couchbase/core/transactions/forward_compat.cxx +220 -0
- data/ext/couchbase/core/transactions/forward_compat.hxx +63 -207
- data/ext/couchbase/core/transactions/internal/atr_cleanup_entry.hxx +110 -102
- data/ext/couchbase/core/transactions/internal/atr_entry.hxx +144 -144
- data/ext/couchbase/core/transactions/internal/client_record.hxx +53 -50
- data/ext/couchbase/core/transactions/internal/doc_record.cxx +5 -5
- data/ext/couchbase/core/transactions/internal/doc_record.hxx +38 -35
- data/ext/couchbase/core/transactions/internal/doc_record_fmt.hxx +17 -16
- data/ext/couchbase/core/transactions/internal/exceptions_internal.hxx +238 -281
- data/ext/couchbase/core/transactions/internal/exceptions_internal_fmt.hxx +103 -0
- data/ext/couchbase/core/transactions/internal/logging.hxx +52 -29
- data/ext/couchbase/core/transactions/internal/transaction_attempt.hxx +3 -3
- data/ext/couchbase/core/transactions/internal/transaction_context.hxx +136 -120
- data/ext/couchbase/core/transactions/internal/transaction_fields.hxx +2 -1
- data/ext/couchbase/core/transactions/internal/transactions_cleanup.hxx +127 -122
- data/ext/couchbase/core/transactions/internal/utils.hxx +244 -219
- data/ext/couchbase/core/transactions/result.cxx +41 -40
- data/ext/couchbase/core/transactions/result.hxx +143 -141
- data/ext/couchbase/core/transactions/result_fmt.hxx +21 -20
- data/ext/couchbase/core/transactions/staged_mutation.cxx +759 -627
- data/ext/couchbase/core/transactions/staged_mutation.hxx +175 -156
- data/ext/couchbase/core/transactions/transaction_context.cxx +231 -179
- data/ext/couchbase/core/transactions/transaction_get_result.cxx +185 -198
- data/ext/couchbase/core/transactions/transaction_get_result.hxx +207 -222
- data/ext/couchbase/core/transactions/transaction_keyspace.cxx +15 -11
- data/ext/couchbase/core/transactions/transaction_links.cxx +11 -7
- data/ext/couchbase/core/transactions/transaction_links.hxx +222 -201
- data/ext/couchbase/core/transactions/transaction_options.cxx +44 -41
- data/ext/couchbase/core/transactions/transactions.cxx +167 -125
- data/ext/couchbase/core/transactions/transactions_cleanup.cxx +491 -424
- data/ext/couchbase/core/transactions/transactions_config.cxx +25 -19
- data/ext/couchbase/core/transactions/uid_generator.cxx +3 -3
- data/ext/couchbase/core/transactions/uid_generator.hxx +2 -2
- data/ext/couchbase/core/transactions/utils.cxx +82 -69
- data/ext/couchbase/core/transactions/waitable_op_list.hxx +154 -140
- data/ext/couchbase/core/transactions.hxx +184 -180
- data/ext/couchbase/core/utils/binary.cxx +3 -3
- data/ext/couchbase/core/utils/binary.hxx +19 -15
- data/ext/couchbase/core/utils/byteswap.hxx +17 -17
- data/ext/couchbase/core/utils/connection_string.cxx +395 -328
- data/ext/couchbase/core/utils/connection_string.hxx +37 -36
- data/ext/couchbase/core/utils/crc32.hxx +42 -34
- data/ext/couchbase/core/utils/duration_parser.cxx +142 -133
- data/ext/couchbase/core/utils/duration_parser.hxx +9 -9
- data/ext/couchbase/core/utils/join_strings.hxx +24 -24
- data/ext/couchbase/core/utils/json.cxx +234 -228
- data/ext/couchbase/core/utils/json.hxx +12 -12
- data/ext/couchbase/core/utils/json_stream_control.hxx +8 -8
- data/ext/couchbase/core/utils/json_streaming_lexer.cxx +288 -263
- data/ext/couchbase/core/utils/json_streaming_lexer.hxx +20 -17
- data/ext/couchbase/core/utils/keyspace.hxx +22 -21
- data/ext/couchbase/core/utils/movable_function.hxx +78 -76
- data/ext/couchbase/core/utils/mutation_token.cxx +7 -3
- data/ext/couchbase/core/utils/mutation_token.hxx +3 -1
- data/ext/couchbase/core/utils/name_codec.hxx +13 -13
- data/ext/couchbase/core/utils/split_string.cxx +9 -9
- data/ext/couchbase/core/utils/split_string.hxx +2 -2
- data/ext/couchbase/core/utils/unsigned_leb128.hxx +92 -88
- data/ext/couchbase/core/utils/url_codec.cxx +301 -297
- data/ext/couchbase/core/utils/url_codec.hxx +35 -35
- data/ext/couchbase/core/vector_query_combination.hxx +4 -1
- data/ext/couchbase/core/view_on_error.hxx +4 -3
- data/ext/couchbase/core/view_query_options.cxx +21 -21
- data/ext/couchbase/core/view_query_options.hxx +23 -22
- data/ext/couchbase/core/view_scan_consistency.hxx +3 -3
- data/ext/couchbase/core/view_sort_order.hxx +4 -1
- data/ext/couchbase/core/wait_until_ready_options.hxx +11 -10
- data/ext/couchbase/couchbase/allow_querying_search_index_options.hxx +11 -11
- data/ext/couchbase/couchbase/analytics_index_manager.hxx +423 -405
- data/ext/couchbase/couchbase/analytics_meta_data.hxx +105 -105
- data/ext/couchbase/couchbase/analytics_metrics.hxx +120 -118
- data/ext/couchbase/couchbase/analytics_options.hxx +318 -292
- data/ext/couchbase/couchbase/analytics_result.hxx +56 -55
- data/ext/couchbase/couchbase/analytics_scan_consistency.hxx +24 -21
- data/ext/couchbase/couchbase/analytics_status.hxx +10 -10
- data/ext/couchbase/couchbase/analytics_warning.hxx +44 -43
- data/ext/couchbase/couchbase/analyze_document_options.hxx +9 -9
- data/ext/couchbase/couchbase/append_options.hxx +51 -47
- data/ext/couchbase/couchbase/behavior_options.hxx +75 -69
- data/ext/couchbase/couchbase/best_effort_retry_strategy.hxx +12 -10
- data/ext/couchbase/couchbase/binary_collection.hxx +213 -183
- data/ext/couchbase/couchbase/boolean_field_query.hxx +38 -38
- data/ext/couchbase/couchbase/boolean_query.hxx +166 -157
- data/ext/couchbase/couchbase/bucket.hxx +69 -68
- data/ext/couchbase/couchbase/bucket_manager.hxx +97 -88
- data/ext/couchbase/couchbase/build_query_index_options.hxx +22 -21
- data/ext/couchbase/couchbase/cas.hxx +74 -73
- data/ext/couchbase/couchbase/certificate_authenticator.hxx +10 -10
- data/ext/couchbase/couchbase/cluster.hxx +266 -310
- data/ext/couchbase/couchbase/cluster_options.hxx +235 -241
- data/ext/couchbase/couchbase/codec/binary_noop_serializer.hxx +11 -11
- data/ext/couchbase/couchbase/codec/codec_flags.hxx +39 -35
- data/ext/couchbase/couchbase/codec/encoded_value.hxx +15 -2
- data/ext/couchbase/couchbase/codec/json_transcoder.hxx +17 -15
- data/ext/couchbase/couchbase/codec/raw_binary_transcoder.hxx +19 -17
- data/ext/couchbase/couchbase/codec/raw_json_transcoder.hxx +31 -24
- data/ext/couchbase/couchbase/codec/raw_string_transcoder.hxx +20 -18
- data/ext/couchbase/couchbase/codec/tao_json_serializer.hxx +38 -30
- data/ext/couchbase/couchbase/collection.hxx +1007 -902
- data/ext/couchbase/couchbase/collection_manager.hxx +115 -107
- data/ext/couchbase/couchbase/collection_query_index_manager.hxx +200 -188
- data/ext/couchbase/couchbase/common_durability_options.hxx +68 -62
- data/ext/couchbase/couchbase/common_options.hxx +67 -67
- data/ext/couchbase/couchbase/compression_options.hxx +33 -33
- data/ext/couchbase/couchbase/configuration_profile.hxx +12 -11
- data/ext/couchbase/couchbase/configuration_profiles_registry.hxx +24 -22
- data/ext/couchbase/couchbase/conjunction_query.hxx +47 -45
- data/ext/couchbase/couchbase/connect_link_analytics_options.hxx +74 -72
- data/ext/couchbase/couchbase/counter_result.hxx +32 -32
- data/ext/couchbase/couchbase/create_bucket_options.hxx +9 -10
- data/ext/couchbase/couchbase/create_collection_options.hxx +35 -34
- data/ext/couchbase/couchbase/create_dataset_analytics_options.hxx +76 -76
- data/ext/couchbase/couchbase/create_dataverse_analytics_options.hxx +44 -44
- data/ext/couchbase/couchbase/create_index_analytics_options.hxx +60 -60
- data/ext/couchbase/couchbase/create_link_analytics_options.hxx +25 -25
- data/ext/couchbase/couchbase/create_primary_query_index_options.hxx +95 -94
- data/ext/couchbase/couchbase/create_query_index_options.hxx +97 -96
- data/ext/couchbase/couchbase/create_scope_options.hxx +9 -9
- data/ext/couchbase/couchbase/date_range.hxx +29 -27
- data/ext/couchbase/couchbase/date_range_facet.hxx +20 -20
- data/ext/couchbase/couchbase/date_range_facet_result.hxx +14 -14
- data/ext/couchbase/couchbase/date_range_query.hxx +219 -205
- data/ext/couchbase/couchbase/decrement_options.hxx +93 -91
- data/ext/couchbase/couchbase/diagnostics_options.hxx +42 -41
- data/ext/couchbase/couchbase/diagnostics_result.hxx +82 -83
- data/ext/couchbase/couchbase/disallow_querying_search_index_options.hxx +11 -10
- data/ext/couchbase/couchbase/disconnect_link_analytics_options.hxx +62 -62
- data/ext/couchbase/couchbase/disjunction_query.hxx +61 -60
- data/ext/couchbase/couchbase/dns_options.hxx +30 -30
- data/ext/couchbase/couchbase/doc_id_query.hxx +69 -69
- data/ext/couchbase/couchbase/drop_bucket_options.hxx +9 -9
- data/ext/couchbase/couchbase/drop_collection_options.hxx +9 -9
- data/ext/couchbase/couchbase/drop_dataset_analytics_options.hxx +60 -60
- data/ext/couchbase/couchbase/drop_dataverse_analytics_options.hxx +44 -44
- data/ext/couchbase/couchbase/drop_index_analytics_options.hxx +60 -60
- data/ext/couchbase/couchbase/drop_link_analytics_options.hxx +25 -25
- data/ext/couchbase/couchbase/drop_primary_query_index_options.hxx +58 -58
- data/ext/couchbase/couchbase/drop_query_index_options.hxx +44 -44
- data/ext/couchbase/couchbase/drop_scope_options.hxx +9 -9
- data/ext/couchbase/couchbase/drop_search_index_options.hxx +9 -9
- data/ext/couchbase/couchbase/durability_level.hxx +32 -29
- data/ext/couchbase/couchbase/endpoint_diagnostics.hxx +171 -171
- data/ext/couchbase/couchbase/endpoint_ping_report.hxx +166 -169
- data/ext/couchbase/couchbase/error.hxx +51 -0
- data/ext/couchbase/couchbase/error_codes.hxx +975 -940
- data/ext/couchbase/couchbase/error_context.hxx +19 -152
- data/ext/couchbase/couchbase/exists_options.hxx +25 -24
- data/ext/couchbase/couchbase/exists_result.hxx +32 -32
- data/ext/couchbase/couchbase/fail_fast_retry_strategy.hxx +4 -4
- data/ext/couchbase/couchbase/flush_bucket_options.hxx +9 -9
- data/ext/couchbase/couchbase/fmt/analytics_scan_consistency.hxx +18 -18
- data/ext/couchbase/couchbase/fmt/analytics_status.hxx +42 -42
- data/ext/couchbase/couchbase/fmt/cas.hxx +10 -10
- data/ext/couchbase/couchbase/fmt/durability_level.hxx +24 -24
- data/ext/couchbase/couchbase/fmt/error.hxx +53 -0
- data/ext/couchbase/couchbase/fmt/error_context.hxx +43 -0
- data/ext/couchbase/couchbase/fmt/mutation_token.hxx +15 -11
- data/ext/couchbase/couchbase/fmt/query_profile.hxx +21 -21
- data/ext/couchbase/couchbase/fmt/query_scan_consistency.hxx +18 -18
- data/ext/couchbase/couchbase/fmt/query_status.hxx +42 -42
- data/ext/couchbase/couchbase/fmt/retry_reason.hxx +75 -75
- data/ext/couchbase/couchbase/fmt/search_scan_consistency.hxx +15 -15
- data/ext/couchbase/couchbase/fmt/tls_verify_mode.hxx +18 -18
- data/ext/couchbase/couchbase/fmt/transaction_keyspace.hxx +15 -11
- data/ext/couchbase/couchbase/fork_event.hxx +12 -12
- data/ext/couchbase/couchbase/freeze_plan_search_index_options.hxx +9 -9
- data/ext/couchbase/couchbase/geo_bounding_box_query.hxx +71 -64
- data/ext/couchbase/couchbase/geo_distance_query.hxx +73 -66
- data/ext/couchbase/couchbase/geo_point.hxx +2 -2
- data/ext/couchbase/couchbase/geo_polygon_query.hxx +40 -39
- data/ext/couchbase/couchbase/get_all_buckets_options.hxx +9 -9
- data/ext/couchbase/couchbase/get_all_datasets_analytics_options.hxx +25 -25
- data/ext/couchbase/couchbase/get_all_indexes_analytics_options.hxx +26 -25
- data/ext/couchbase/couchbase/get_all_query_indexes_options.hxx +27 -25
- data/ext/couchbase/couchbase/get_all_replicas_options.hxx +49 -26
- data/ext/couchbase/couchbase/get_all_scopes_options.hxx +9 -9
- data/ext/couchbase/couchbase/get_all_search_indexes_options.hxx +9 -9
- data/ext/couchbase/couchbase/get_and_lock_options.hxx +25 -24
- data/ext/couchbase/couchbase/get_and_touch_options.hxx +25 -24
- data/ext/couchbase/couchbase/get_any_replica_options.hxx +49 -26
- data/ext/couchbase/couchbase/get_bucket_options.hxx +9 -9
- data/ext/couchbase/couchbase/get_indexed_search_index_options.hxx +9 -9
- data/ext/couchbase/couchbase/get_links_analytics_options.hxx +74 -74
- data/ext/couchbase/couchbase/get_options.hxx +63 -60
- data/ext/couchbase/couchbase/get_pending_mutations_analytics_options.hxx +30 -28
- data/ext/couchbase/couchbase/get_replica_result.hxx +79 -75
- data/ext/couchbase/couchbase/get_result.hxx +86 -80
- data/ext/couchbase/couchbase/get_search_index_options.hxx +9 -9
- data/ext/couchbase/couchbase/highlight_style.hxx +14 -14
- data/ext/couchbase/couchbase/increment_options.hxx +94 -91
- data/ext/couchbase/couchbase/insert_options.hxx +62 -59
- data/ext/couchbase/couchbase/ip_protocol.hxx +3 -3
- data/ext/couchbase/couchbase/logger.hxx +51 -0
- data/ext/couchbase/couchbase/lookup_in_all_replicas_options.hxx +54 -43
- data/ext/couchbase/couchbase/lookup_in_any_replica_options.hxx +54 -44
- data/ext/couchbase/couchbase/lookup_in_options.hxx +40 -40
- data/ext/couchbase/couchbase/lookup_in_replica_result.hxx +38 -35
- data/ext/couchbase/couchbase/lookup_in_result.hxx +222 -216
- data/ext/couchbase/couchbase/lookup_in_specs.hxx +101 -101
- data/ext/couchbase/couchbase/management/analytics_dataset.hxx +16 -16
- data/ext/couchbase/couchbase/management/analytics_index.hxx +16 -16
- data/ext/couchbase/couchbase/management/analytics_link.hxx +193 -189
- data/ext/couchbase/couchbase/management/bucket_settings.hxx +91 -75
- data/ext/couchbase/couchbase/management/collection_spec.hxx +4 -4
- data/ext/couchbase/couchbase/management/query_index.hxx +10 -10
- data/ext/couchbase/couchbase/management/scope_spec.hxx +2 -2
- data/ext/couchbase/couchbase/management/search_index.hxx +9 -9
- data/ext/couchbase/couchbase/match_all_query.hxx +10 -9
- data/ext/couchbase/couchbase/match_none_query.hxx +10 -9
- data/ext/couchbase/couchbase/match_operator.hxx +15 -14
- data/ext/couchbase/couchbase/match_phrase_query.hxx +70 -65
- data/ext/couchbase/couchbase/match_query.hxx +115 -114
- data/ext/couchbase/couchbase/metrics/meter.hxx +33 -30
- data/ext/couchbase/couchbase/metrics/otel_meter.hxx +86 -74
- data/ext/couchbase/couchbase/metrics_options.hxx +34 -34
- data/ext/couchbase/couchbase/mutate_in_options.hxx +160 -149
- data/ext/couchbase/couchbase/mutate_in_result.hxx +130 -123
- data/ext/couchbase/couchbase/mutate_in_specs.hxx +473 -454
- data/ext/couchbase/couchbase/mutation_result.hxx +32 -32
- data/ext/couchbase/couchbase/mutation_state.hxx +35 -34
- data/ext/couchbase/couchbase/mutation_token.hxx +78 -78
- data/ext/couchbase/couchbase/network_options.hxx +101 -72
- data/ext/couchbase/couchbase/numeric_range.hxx +26 -26
- data/ext/couchbase/couchbase/numeric_range_facet.hxx +20 -20
- data/ext/couchbase/couchbase/numeric_range_facet_result.hxx +14 -14
- data/ext/couchbase/couchbase/numeric_range_query.hxx +97 -95
- data/ext/couchbase/couchbase/password_authenticator.hxx +17 -17
- data/ext/couchbase/couchbase/pause_ingest_search_index_options.hxx +11 -10
- data/ext/couchbase/couchbase/persist_to.hxx +45 -44
- data/ext/couchbase/couchbase/phrase_query.hxx +69 -65
- data/ext/couchbase/couchbase/ping_options.hxx +55 -54
- data/ext/couchbase/couchbase/ping_result.hxx +79 -77
- data/ext/couchbase/couchbase/prefix_query.hxx +43 -40
- data/ext/couchbase/couchbase/prepend_options.hxx +51 -47
- data/ext/couchbase/couchbase/query_index_manager.hxx +207 -199
- data/ext/couchbase/couchbase/query_meta_data.hxx +120 -120
- data/ext/couchbase/couchbase/query_metrics.hxx +135 -133
- data/ext/couchbase/couchbase/query_options.hxx +518 -493
- data/ext/couchbase/couchbase/query_profile.hxx +29 -26
- data/ext/couchbase/couchbase/query_result.hxx +56 -55
- data/ext/couchbase/couchbase/query_scan_consistency.hxx +24 -21
- data/ext/couchbase/couchbase/query_status.hxx +10 -10
- data/ext/couchbase/couchbase/query_string_query.hxx +34 -29
- data/ext/couchbase/couchbase/query_warning.hxx +75 -71
- data/ext/couchbase/couchbase/read_preference.hxx +58 -0
- data/ext/couchbase/couchbase/regexp_query.hxx +40 -39
- data/ext/couchbase/couchbase/remove_options.hxx +51 -47
- data/ext/couchbase/couchbase/replace_link_analytics_options.hxx +25 -25
- data/ext/couchbase/couchbase/replace_options.hxx +112 -104
- data/ext/couchbase/couchbase/replicate_to.hxx +28 -28
- data/ext/couchbase/couchbase/result.hxx +28 -28
- data/ext/couchbase/couchbase/resume_ingest_search_index_options.hxx +11 -10
- data/ext/couchbase/couchbase/retry_action.hxx +10 -10
- data/ext/couchbase/couchbase/retry_reason.hxx +53 -51
- data/ext/couchbase/couchbase/retry_request.hxx +7 -7
- data/ext/couchbase/couchbase/retry_strategy.hxx +4 -4
- data/ext/couchbase/couchbase/scan_options.hxx +114 -108
- data/ext/couchbase/couchbase/scan_result.hxx +97 -96
- data/ext/couchbase/couchbase/scan_result_item.hxx +120 -118
- data/ext/couchbase/couchbase/scan_type.hxx +237 -232
- data/ext/couchbase/couchbase/scope.hxx +164 -157
- data/ext/couchbase/couchbase/scope_search_index_manager.hxx +263 -238
- data/ext/couchbase/couchbase/search_date_range.hxx +32 -29
- data/ext/couchbase/couchbase/search_facet.hxx +25 -25
- data/ext/couchbase/couchbase/search_facet_result.hxx +11 -11
- data/ext/couchbase/couchbase/search_geo_distance_units.hxx +11 -1
- data/ext/couchbase/couchbase/search_index_manager.hxx +261 -238
- data/ext/couchbase/couchbase/search_meta_data.hxx +37 -37
- data/ext/couchbase/couchbase/search_metrics.hxx +84 -83
- data/ext/couchbase/couchbase/search_numeric_range.hxx +32 -32
- data/ext/couchbase/couchbase/search_options.hxx +449 -435
- data/ext/couchbase/couchbase/search_query.hxx +32 -30
- data/ext/couchbase/couchbase/search_request.hxx +69 -68
- data/ext/couchbase/couchbase/search_result.hxx +29 -26
- data/ext/couchbase/couchbase/search_row.hxx +52 -52
- data/ext/couchbase/couchbase/search_row_location.hxx +20 -20
- data/ext/couchbase/couchbase/search_row_locations.hxx +39 -38
- data/ext/couchbase/couchbase/search_scan_consistency.hxx +11 -10
- data/ext/couchbase/couchbase/search_sort.hxx +20 -20
- data/ext/couchbase/couchbase/search_sort_field.hxx +77 -71
- data/ext/couchbase/couchbase/search_sort_field_missing.hxx +2 -2
- data/ext/couchbase/couchbase/search_sort_field_mode.hxx +3 -3
- data/ext/couchbase/couchbase/search_sort_field_type.hxx +4 -4
- data/ext/couchbase/couchbase/search_sort_geo_distance.hxx +41 -41
- data/ext/couchbase/couchbase/search_sort_id.hxx +23 -23
- data/ext/couchbase/couchbase/search_sort_score.hxx +23 -23
- data/ext/couchbase/couchbase/search_term_range.hxx +17 -17
- data/ext/couchbase/couchbase/security_options.hxx +50 -50
- data/ext/couchbase/couchbase/service_type.hxx +34 -34
- data/ext/couchbase/couchbase/store_semantics.hxx +28 -28
- data/ext/couchbase/couchbase/subdoc/array_add_unique.hxx +54 -54
- data/ext/couchbase/couchbase/subdoc/array_append.hxx +40 -40
- data/ext/couchbase/couchbase/subdoc/array_insert.hxx +41 -41
- data/ext/couchbase/couchbase/subdoc/array_prepend.hxx +41 -41
- data/ext/couchbase/couchbase/subdoc/count.hxx +24 -24
- data/ext/couchbase/couchbase/subdoc/counter.hxx +41 -41
- data/ext/couchbase/couchbase/subdoc/exists.hxx +24 -24
- data/ext/couchbase/couchbase/subdoc/get.hxx +45 -29
- data/ext/couchbase/couchbase/subdoc/insert.hxx +70 -54
- data/ext/couchbase/couchbase/subdoc/lookup_in_macro.hxx +13 -12
- data/ext/couchbase/couchbase/subdoc/mutate_in_macro.hxx +7 -2
- data/ext/couchbase/couchbase/subdoc/remove.hxx +24 -24
- data/ext/couchbase/couchbase/subdoc/replace.hxx +55 -39
- data/ext/couchbase/couchbase/subdoc/upsert.hxx +70 -54
- data/ext/couchbase/couchbase/term_facet.hxx +16 -16
- data/ext/couchbase/couchbase/term_facet_result.hxx +14 -14
- data/ext/couchbase/couchbase/term_query.hxx +107 -104
- data/ext/couchbase/couchbase/term_range_query.hxx +99 -96
- data/ext/couchbase/couchbase/timeout_options.hxx +118 -112
- data/ext/couchbase/couchbase/tls_verify_mode.hxx +2 -2
- data/ext/couchbase/couchbase/touch_options.hxx +25 -24
- data/ext/couchbase/couchbase/tracing/otel_tracer.hxx +45 -44
- data/ext/couchbase/couchbase/tracing/request_span.hxx +34 -34
- data/ext/couchbase/couchbase/tracing/request_tracer.hxx +27 -25
- data/ext/couchbase/couchbase/tracing_options.hxx +147 -142
- data/ext/couchbase/couchbase/transactions/async_attempt_context.hxx +149 -115
- data/ext/couchbase/couchbase/transactions/attempt_context.hxx +146 -95
- data/ext/couchbase/couchbase/transactions/transaction_get_result.hxx +52 -80
- data/ext/couchbase/couchbase/transactions/transaction_keyspace.hxx +33 -29
- data/ext/couchbase/couchbase/transactions/transaction_options.hxx +101 -96
- data/ext/couchbase/couchbase/transactions/transaction_query_options.hxx +228 -223
- data/ext/couchbase/couchbase/transactions/transaction_query_result.hxx +11 -12
- data/ext/couchbase/couchbase/transactions/transaction_result.hxx +2 -3
- data/ext/couchbase/couchbase/transactions/transactions_cleanup_config.hxx +105 -104
- data/ext/couchbase/couchbase/transactions/transactions_config.hxx +191 -187
- data/ext/couchbase/couchbase/transactions/transactions_query_config.hxx +32 -32
- data/ext/couchbase/couchbase/transactions.hxx +56 -37
- data/ext/couchbase/couchbase/unfreeze_plan_search_index_options.hxx +11 -10
- data/ext/couchbase/couchbase/unlock_options.hxx +25 -24
- data/ext/couchbase/couchbase/update_bucket_options.hxx +9 -9
- data/ext/couchbase/couchbase/update_collection_options.hxx +35 -34
- data/ext/couchbase/couchbase/upsert_options.hxx +85 -80
- data/ext/couchbase/couchbase/upsert_search_index_options.hxx +9 -9
- data/ext/couchbase/couchbase/vector_query.hxx +82 -62
- data/ext/couchbase/couchbase/vector_search.hxx +51 -47
- data/ext/couchbase/couchbase/vector_search_options.hxx +45 -41
- data/ext/couchbase/couchbase/wan_development_configuration_profile.hxx +13 -13
- data/ext/couchbase/couchbase/watch_query_indexes_options.hxx +41 -41
- data/ext/couchbase/couchbase/wildcard_query.hxx +42 -41
- data/ext/couchbase/third_party/expected/include/tl/expected.hpp +1746 -1584
- data/ext/couchbase/third_party/jsonsl/jsonsl.c +2664 -2638
- data/ext/couchbase/third_party/jsonsl/jsonsl.h +359 -342
- data/ext/couchbase.cxx +43 -9568
- data/ext/extconf.rb +5 -0
- data/ext/rcb_analytics.cxx +1195 -0
- data/ext/rcb_analytics.hxx +29 -0
- data/ext/rcb_backend.cxx +530 -0
- data/ext/rcb_backend.hxx +46 -0
- data/ext/rcb_buckets.cxx +624 -0
- data/ext/rcb_buckets.hxx +29 -0
- data/ext/rcb_collections.cxx +377 -0
- data/ext/rcb_collections.hxx +29 -0
- data/ext/rcb_crud.cxx +1544 -0
- data/ext/rcb_crud.hxx +29 -0
- data/ext/rcb_diagnostics.cxx +264 -0
- data/ext/rcb_diagnostics.hxx +29 -0
- data/ext/rcb_exceptions.cxx +963 -0
- data/ext/rcb_exceptions.hxx +111 -0
- data/ext/rcb_extras.cxx +394 -0
- data/ext/rcb_extras.hxx +29 -0
- data/ext/rcb_logger.cxx +319 -0
- data/ext/rcb_logger.hxx +36 -0
- data/ext/rcb_multi.cxx +343 -0
- data/ext/rcb_multi.hxx +29 -0
- data/ext/rcb_query.cxx +1316 -0
- data/ext/rcb_query.hxx +29 -0
- data/ext/rcb_range_scan.cxx +358 -0
- data/ext/rcb_range_scan.hxx +29 -0
- data/ext/rcb_search.cxx +1216 -0
- data/ext/rcb_search.hxx +29 -0
- data/ext/rcb_users.cxx +636 -0
- data/ext/rcb_users.hxx +29 -0
- data/ext/rcb_utils.cxx +590 -0
- data/ext/rcb_utils.hxx +564 -0
- data/ext/rcb_version.cxx +137 -0
- data/ext/rcb_version.hxx +34 -0
- data/ext/rcb_views.cxx +485 -0
- data/ext/rcb_views.hxx +29 -0
- data/lib/active_support/cache/couchbase_store.rb +4 -1
- data/lib/couchbase/analytics_options.rb +2 -0
- data/lib/couchbase/authenticator.rb +2 -0
- data/lib/couchbase/binary_collection.rb +2 -0
- data/lib/couchbase/binary_collection_options.rb +2 -0
- data/lib/couchbase/bucket.rb +2 -0
- data/lib/couchbase/cluster.rb +2 -0
- data/lib/couchbase/collection.rb +3 -1
- data/lib/couchbase/collection_options.rb +2 -0
- data/lib/couchbase/config_profiles.rb +2 -0
- data/lib/couchbase/configuration.rb +2 -0
- data/lib/couchbase/datastructures/couchbase_list.rb +4 -4
- data/lib/couchbase/datastructures/couchbase_map.rb +4 -4
- data/lib/couchbase/datastructures/couchbase_queue.rb +4 -4
- data/lib/couchbase/datastructures/couchbase_set.rb +4 -4
- data/lib/couchbase/datastructures.rb +2 -0
- data/lib/couchbase/diagnostics.rb +2 -0
- data/lib/couchbase/errors.rb +46 -8
- data/lib/couchbase/json_transcoder.rb +2 -0
- data/lib/couchbase/key_value_scan.rb +2 -0
- data/lib/couchbase/logger.rb +2 -0
- data/lib/couchbase/management/analytics_index_manager.rb +2 -0
- data/lib/couchbase/management/bucket_manager.rb +2 -0
- data/lib/couchbase/management/collection_manager.rb +2 -0
- data/lib/couchbase/management/collection_query_index_manager.rb +2 -0
- data/lib/couchbase/management/query_index_manager.rb +2 -0
- data/lib/couchbase/management/scope_search_index_manager.rb +2 -0
- data/lib/couchbase/management/search_index_manager.rb +2 -0
- data/lib/couchbase/management/user_manager.rb +2 -0
- data/lib/couchbase/management/view_index_manager.rb +2 -0
- data/lib/couchbase/management.rb +2 -0
- data/lib/couchbase/mutation_state.rb +2 -0
- data/lib/couchbase/options.rb +2 -0
- data/lib/couchbase/protostellar/request_generator/kv.rb +1 -1
- data/lib/couchbase/query_options.rb +2 -0
- data/lib/couchbase/railtie.rb +2 -0
- data/lib/couchbase/raw_binary_transcoder.rb +2 -0
- data/lib/couchbase/raw_json_transcoder.rb +2 -0
- data/lib/couchbase/raw_string_transcoder.rb +2 -0
- data/lib/couchbase/scope.rb +2 -0
- data/lib/couchbase/search_options.rb +91 -63
- data/lib/couchbase/subdoc.rb +5 -3
- data/lib/couchbase/transcoder_flags.rb +2 -0
- data/lib/couchbase/utils/generic_logger_adapter.rb +3 -1
- data/lib/couchbase/utils/stdlib_logger_adapter.rb +2 -0
- data/lib/couchbase/utils/time.rb +3 -1
- data/lib/couchbase/utils.rb +2 -0
- data/lib/couchbase/version.rb +3 -1
- data/lib/couchbase/view_options.rb +2 -0
- data/lib/couchbase.rb +2 -0
- data/lib/rails/generators/couchbase/config/config_generator.rb +2 -0
- metadata +83 -26
- data/ext/couchbase/core/impl/internal_manager_error_context.cxx +0 -113
- data/ext/couchbase/core/impl/internal_manager_error_context.hxx +0 -60
- data/ext/couchbase/core/impl/manager_error_context.cxx +0 -100
- data/ext/couchbase/core/impl/search_error_context.cxx +0 -147
- data/ext/couchbase/couchbase/analytics_error_context.hxx +0 -143
- data/ext/couchbase/couchbase/fmt/key_value_error_map_attribute.hxx +0 -100
- data/ext/couchbase/couchbase/fmt/key_value_status_code.hxx +0 -269
- data/ext/couchbase/couchbase/key_value_error_context.hxx +0 -229
- data/ext/couchbase/couchbase/key_value_error_map_attribute.hxx +0 -136
- data/ext/couchbase/couchbase/key_value_error_map_info.hxx +0 -138
- data/ext/couchbase/couchbase/key_value_extended_error_info.hxx +0 -86
- data/ext/couchbase/couchbase/key_value_status_code.hxx +0 -109
- data/ext/couchbase/couchbase/manager_error_context.hxx +0 -111
- data/ext/couchbase/couchbase/query_error_context.hxx +0 -145
- data/ext/couchbase/couchbase/search_error_context.hxx +0 -138
- data/ext/couchbase/couchbase/subdocument_error_context.hxx +0 -147
- 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)
|
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
|
-
|
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
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
205
|
+
return unexpected<typename std::decay<E>::type>(std::forward<E>(e));
|
205
206
|
}
|
206
207
|
|
207
208
|
struct unexpect_t {
|
208
|
-
|
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
|
-
|
220
|
+
throw std::forward<E>(e);
|
220
221
|
#else
|
221
222
|
#ifdef _MSC_VER
|
222
|
-
|
223
|
+
__assume(0);
|
223
224
|
#else
|
224
|
-
|
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 &&
|
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
|
-
|
310
|
+
return std::mem_fn(f)(std::forward<Args>(args)...);
|
309
311
|
}
|
310
312
|
|
311
|
-
template<typename Fn,
|
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
|
-
|
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,
|
325
|
-
|
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,
|
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 &&
|
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 ||
|
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
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
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 &&
|
427
|
-
!std::is_same<
|
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 &&
|
433
|
-
!std::is_constructible<T,
|
434
|
-
!std::
|
435
|
-
!std::
|
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,
|
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
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
}
|
519
|
-
|
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
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
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
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
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
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
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
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
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
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
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
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
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
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
}
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
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
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
913
|
+
try {
|
914
|
+
construct(rhs.get());
|
915
|
+
} catch (...) {
|
916
|
+
geterr() = std::move(tmp);
|
917
|
+
throw;
|
918
|
+
}
|
855
919
|
#else
|
856
|
-
|
920
|
+
construct(rhs.get());
|
857
921
|
#endif
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
}
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
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
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
948
|
+
try {
|
949
|
+
construct(std::move(rhs).get());
|
950
|
+
} catch (...) {
|
951
|
+
geterr() = std::move(tmp);
|
952
|
+
throw;
|
953
|
+
}
|
888
954
|
#else
|
889
|
-
|
955
|
+
construct(std::move(rhs).get());
|
890
956
|
#endif
|
891
|
-
|
892
|
-
|
893
|
-
}
|
957
|
+
} else {
|
958
|
+
assign_common(std::move(rhs));
|
894
959
|
}
|
960
|
+
}
|
895
961
|
|
896
962
|
#else
|
897
963
|
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
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
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
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
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
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
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
1023
|
+
constexpr const T&& get() const&&
|
1024
|
+
{
|
1025
|
+
return std::move(this->m_val);
|
1026
|
+
}
|
961
1027
|
#endif
|
962
1028
|
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
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
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
1042
|
+
constexpr const unexpected<E>&& geterr() const&&
|
1043
|
+
{
|
1044
|
+
return std::move(this->m_unexpect);
|
1045
|
+
}
|
980
1046
|
#endif
|
981
1047
|
|
982
|
-
|
983
|
-
|
984
|
-
|
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
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
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
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1116
|
+
constexpr const unexpected<E>&& geterr() const&&
|
1117
|
+
{
|
1118
|
+
return std::move(this->m_unexpect);
|
1119
|
+
}
|
1054
1120
|
#endif
|
1055
1121
|
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
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&&
|
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
|
-
|
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
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
}
|
1125
|
-
|
1126
|
-
|
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
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
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
|
-
|
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
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
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
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
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
|
-
|
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
|
-
|
1252
|
+
using expected_copy_assign_base<T, E>::expected_copy_assign_base;
|
1182
1253
|
|
1183
|
-
|
1184
|
-
|
1254
|
+
expected_move_assign_base() = default;
|
1255
|
+
expected_move_assign_base(const expected_move_assign_base& rhs) = default;
|
1185
1256
|
|
1186
|
-
|
1257
|
+
expected_move_assign_base(expected_move_assign_base&& rhs) = default;
|
1187
1258
|
|
1188
|
-
|
1259
|
+
expected_move_assign_base& operator=(const expected_move_assign_base& rhs) = default;
|
1189
1260
|
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
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 =
|
1203
|
-
|
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
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
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
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
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
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
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
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
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 =
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
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
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
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
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
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
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
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
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
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
|
-
|
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,
|
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
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
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
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
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
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
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
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
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
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
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
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
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
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
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) &&
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
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
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
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
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
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) &&
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
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
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
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
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
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) &&
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
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
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
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
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
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
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
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
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
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
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
{
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
{
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
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
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
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
|
-
|
1825
|
-
|
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
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
}
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
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
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
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
|
-
|
1891
|
-
|
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
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
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
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
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
|
-
|
1933
|
-
|
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
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
1976
|
-
|
1977
|
-
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
1984
|
-
|
1985
|
-
|
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
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
1992
|
-
|
1993
|
-
|
1994
|
-
|
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
|
-
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
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
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
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
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
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
|
-
|
2020
|
-
|
2021
|
-
|
2022
|
-
|
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
|
-
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2032
|
-
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
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
|
-
|
2302
|
+
static_assert(detail::is_expected<Ret>::value, "F must return an expected");
|
2164
2303
|
|
2165
|
-
|
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
|
-
|
2315
|
+
static_assert(detail::is_expected<Ret>::value, "F must return an expected");
|
2176
2316
|
|
2177
|
-
|
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
|
-
|
2330
|
+
static_assert(detail::is_expected<Ret>::value, "F must return an expected");
|
2190
2331
|
|
2191
|
-
|
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
|
-
|
2343
|
+
static_assert(detail::is_expected<Ret>::value, "F must return an expected");
|
2202
2344
|
|
2203
|
-
|
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
|
-
|
2217
|
-
|
2218
|
-
|
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
|
-
|
2230
|
-
|
2231
|
-
|
2232
|
-
|
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
|
-
|
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
|
-
|
2247
|
-
|
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
|
-
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
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
|
-
|
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
|
-
|
2420
|
+
using result = ret_t<Exp, detail::decay_t<Ret>>;
|
2277
2421
|
|
2278
|
-
|
2279
|
-
|
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
|
-
|
2292
|
-
|
2293
|
-
|
2294
|
-
|
2435
|
+
if (exp.has_value()) {
|
2436
|
+
detail::invoke(std::forward<F>(f), *std::forward<Exp>(exp));
|
2437
|
+
return {};
|
2438
|
+
}
|
2295
2439
|
|
2296
|
-
|
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
|
-
|
2452
|
+
using result = ret_t<Exp, detail::decay_t<Ret>>;
|
2309
2453
|
|
2310
|
-
|
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
|
-
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2467
|
+
if (exp.has_value()) {
|
2468
|
+
detail::invoke(std::forward<F>(f));
|
2469
|
+
return {};
|
2470
|
+
}
|
2326
2471
|
|
2327
|
-
|
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) &&
|
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
|
-
|
2341
|
-
|
2342
|
-
|
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
|
-
|
2353
|
-
|
2354
|
-
|
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
|
-
|
2358
|
-
|
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
|
-
|
2369
|
-
|
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
|
-
|
2380
|
-
|
2381
|
-
|
2382
|
-
|
2528
|
+
using result = expected<exp_t<Exp>, monostate>;
|
2529
|
+
if (exp.has_value()) {
|
2530
|
+
return result();
|
2531
|
+
}
|
2383
2532
|
|
2384
|
-
|
2385
|
-
|
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
|
-
|
2545
|
+
using result = expected<exp_t<Exp>, detail::decay_t<Ret>>;
|
2397
2546
|
|
2398
|
-
|
2399
|
-
|
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
|
-
|
2411
|
-
|
2412
|
-
|
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
|
-
|
2416
|
-
|
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
|
-
|
2577
|
+
using result = expected<exp_t<Exp>, detail::decay_t<Ret>>;
|
2428
2578
|
|
2429
|
-
|
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
|
-
|
2441
|
-
|
2442
|
-
|
2443
|
-
|
2592
|
+
using result = expected<exp_t<Exp>, monostate>;
|
2593
|
+
if (exp.has_value()) {
|
2594
|
+
return result();
|
2595
|
+
}
|
2444
2596
|
|
2445
|
-
|
2446
|
-
|
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
|
-
|
2459
|
-
|
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
|
-
|
2470
|
-
|
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
|
-
|
2481
|
-
|
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
|
-
|
2492
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
2717
|
+
return x.has_value() ? true : x.error() != e.value();
|
2558
2718
|
}
|
2559
2719
|
|
2560
|
-
template<
|
2561
|
-
|
2562
|
-
|
2563
|
-
|
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
|
-
|
2729
|
+
lhs.swap(rhs);
|
2568
2730
|
}
|
2569
2731
|
} // namespace tl
|
2570
2732
|
|