grpc 1.31.0.pre1 → 1.33.0.pre1

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

Potentially problematic release.


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

Files changed (614) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +693 -16022
  3. data/include/grpc/grpc.h +0 -5
  4. data/include/grpc/grpc_security.h +47 -14
  5. data/include/grpc/impl/codegen/README.md +22 -0
  6. data/include/grpc/impl/codegen/grpc_types.h +0 -5
  7. data/include/grpc/impl/codegen/port_platform.h +6 -1
  8. data/src/core/ext/filters/client_channel/backup_poller.cc +3 -2
  9. data/src/core/ext/filters/client_channel/client_channel.cc +264 -186
  10. data/src/core/ext/filters/client_channel/client_channel.h +1 -1
  11. data/src/core/ext/filters/client_channel/client_channel_channelz.h +0 -3
  12. data/src/core/ext/filters/client_channel/config_selector.cc +0 -4
  13. data/src/core/ext/filters/client_channel/config_selector.h +34 -5
  14. data/src/core/ext/filters/client_channel/health/health_check_client.cc +6 -1
  15. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +2 -3
  16. data/src/core/ext/filters/client_channel/lb_policy.h +3 -1
  17. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +48 -35
  18. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +7 -5
  19. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +9 -6
  20. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +126 -119
  21. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +0 -13
  22. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +0 -3
  23. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -37
  24. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +21 -15
  25. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +32 -13
  26. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +8 -7
  27. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +9 -32
  28. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +26 -16
  29. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +207 -129
  30. data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +453 -255
  31. data/src/core/ext/filters/client_channel/lb_policy/xds/eds_drop.cc +571 -0
  32. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +727 -0
  33. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +8 -1
  34. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -1
  35. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +3 -3
  36. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +1 -1
  37. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
  38. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +1 -1
  39. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -1
  40. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +602 -58
  41. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +28 -0
  42. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +8 -39
  43. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +4 -3
  44. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +49 -47
  45. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +5 -9
  46. data/src/core/ext/filters/client_channel/server_address.cc +120 -7
  47. data/src/core/ext/filters/client_channel/server_address.h +48 -21
  48. data/src/core/ext/filters/client_channel/service_config.cc +16 -13
  49. data/src/core/ext/filters/client_channel/service_config.h +7 -4
  50. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +2 -2
  51. data/src/core/ext/filters/client_channel/service_config_parser.cc +8 -6
  52. data/src/core/ext/filters/client_channel/service_config_parser.h +8 -5
  53. data/src/core/ext/filters/client_channel/subchannel.cc +64 -23
  54. data/src/core/ext/filters/client_channel/subchannel.h +16 -4
  55. data/src/core/ext/filters/client_channel/subchannel_interface.h +44 -0
  56. data/src/core/ext/filters/max_age/max_age_filter.cc +2 -1
  57. data/src/core/ext/filters/message_size/message_size_filter.cc +2 -1
  58. data/src/core/ext/filters/message_size/message_size_filter.h +2 -1
  59. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +87 -31
  60. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +18 -1
  61. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +10 -35
  62. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +19 -25
  63. data/src/core/ext/transport/chttp2/server/chttp2_server.h +2 -1
  64. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +2 -2
  65. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +6 -6
  66. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +3 -2
  67. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +256 -287
  68. data/src/core/ext/transport/chttp2/transport/flow_control.cc +11 -3
  69. data/src/core/ext/transport/chttp2/transport/flow_control.h +10 -0
  70. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +2 -2
  71. data/src/core/ext/transport/chttp2/transport/internal.h +10 -1
  72. data/src/core/ext/transport/chttp2/transport/parsing.cc +17 -30
  73. data/src/core/ext/transport/chttp2/transport/writing.cc +6 -5
  74. data/src/core/ext/transport/inproc/inproc_transport.cc +12 -12
  75. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +244 -0
  76. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +766 -0
  77. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +74 -0
  78. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +226 -0
  79. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +458 -0
  80. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +1635 -0
  81. data/src/core/ext/upb-generated/envoy/{api/v2/cluster → config/cluster/v3}/filter.upb.c +8 -8
  82. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +69 -0
  83. data/src/core/ext/upb-generated/envoy/{api/v2/cluster → config/cluster/v3}/outlier_detection.upb.c +8 -8
  84. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +323 -0
  85. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +124 -0
  86. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +379 -0
  87. data/src/core/ext/upb-generated/envoy/{api/v2/core → config/core/v3}/backoff.upb.c +8 -8
  88. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +79 -0
  89. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +310 -0
  90. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +869 -0
  91. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +103 -0
  92. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +351 -0
  93. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +34 -0
  94. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +71 -0
  95. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +53 -0
  96. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +133 -0
  97. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +241 -0
  98. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +752 -0
  99. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +170 -0
  100. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +684 -0
  101. data/src/core/ext/upb-generated/envoy/{api/v2/core → config/core/v3}/http_uri.upb.c +8 -8
  102. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +80 -0
  103. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +176 -0
  104. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +645 -0
  105. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +28 -0
  106. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +58 -0
  107. data/src/core/ext/upb-generated/envoy/{api/v2/core → config/core/v3}/socket_option.upb.c +6 -6
  108. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +88 -0
  109. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +36 -0
  110. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +85 -0
  111. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +91 -0
  112. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +220 -0
  113. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +91 -0
  114. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +273 -0
  115. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +112 -0
  116. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +332 -0
  117. data/src/core/ext/upb-generated/envoy/config/listener/{v2 → v3}/api_listener.upb.c +8 -8
  118. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +65 -0
  119. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +128 -0
  120. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +467 -0
  121. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +155 -0
  122. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +539 -0
  123. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +41 -0
  124. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +94 -0
  125. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +178 -0
  126. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +616 -0
  127. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +63 -0
  128. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +204 -0
  129. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +900 -0
  130. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +3290 -0
  131. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +60 -0
  132. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +139 -0
  133. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +50 -0
  134. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +108 -0
  135. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +364 -0
  136. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +1336 -0
  137. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.c +20 -0
  138. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.h +34 -0
  139. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +110 -0
  140. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +387 -0
  141. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +76 -0
  142. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +214 -0
  143. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +147 -0
  144. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +570 -0
  145. data/src/core/ext/upb-generated/envoy/{api/v2 → service/cluster/v3}/cds.upb.c +5 -6
  146. data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.h +49 -0
  147. data/src/core/ext/upb-generated/envoy/service/discovery/{v2 → v3}/ads.upb.c +5 -4
  148. data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.h +49 -0
  149. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +139 -0
  150. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +449 -0
  151. data/src/core/ext/upb-generated/envoy/{api/v2 → service/endpoint/v3}/eds.upb.c +5 -6
  152. data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.h +49 -0
  153. data/src/core/ext/upb-generated/envoy/{api/v2 → service/listener/v3}/lds.upb.c +5 -6
  154. data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.h +49 -0
  155. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +55 -0
  156. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +136 -0
  157. data/src/core/ext/upb-generated/envoy/{api/v2 → service/route/v3}/rds.upb.c +5 -6
  158. data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.h +49 -0
  159. data/src/core/ext/upb-generated/envoy/{api/v2 → service/route/v3}/srds.upb.c +5 -6
  160. data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.h +49 -0
  161. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +47 -0
  162. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +114 -0
  163. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +35 -0
  164. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +77 -0
  165. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +34 -0
  166. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +71 -0
  167. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +64 -0
  168. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +145 -0
  169. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +54 -0
  170. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +133 -0
  171. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +63 -0
  172. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +188 -0
  173. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +88 -0
  174. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +258 -0
  175. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +90 -0
  176. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +250 -0
  177. data/src/core/ext/upb-generated/envoy/type/{http.upb.c → v3/http.upb.c} +2 -2
  178. data/src/core/ext/upb-generated/envoy/type/{http.upb.h → v3/http.upb.h} +8 -8
  179. data/src/core/ext/upb-generated/envoy/type/{percent.upb.c → v3/percent.upb.c} +9 -8
  180. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +86 -0
  181. data/src/core/ext/upb-generated/envoy/type/{range.upb.c → v3/range.upb.c} +12 -11
  182. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +111 -0
  183. data/src/core/ext/upb-generated/envoy/type/{semantic_version.upb.c → v3/semantic_version.upb.c} +6 -5
  184. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +61 -0
  185. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +242 -0
  186. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +753 -0
  187. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +234 -0
  188. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +759 -0
  189. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +36 -36
  190. data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +1 -1
  191. data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +31 -0
  192. data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +57 -0
  193. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +27 -0
  194. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +53 -0
  195. data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.c +28 -0
  196. data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.h +53 -0
  197. data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.c +52 -0
  198. data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.h +129 -0
  199. data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.c +42 -0
  200. data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.h +77 -0
  201. data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.c +36 -0
  202. data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.h +85 -0
  203. data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.c +54 -0
  204. data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.h +160 -0
  205. data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.c +36 -0
  206. data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.h +84 -0
  207. data/src/core/ext/upb-generated/validate/validate.upb.c +11 -11
  208. data/src/core/ext/upb-generated/validate/validate.upb.h +1 -1
  209. data/src/core/ext/xds/certificate_provider_factory.h +59 -0
  210. data/src/core/ext/xds/certificate_provider_registry.cc +103 -0
  211. data/src/core/ext/xds/certificate_provider_registry.h +57 -0
  212. data/src/core/ext/xds/certificate_provider_store.h +50 -0
  213. data/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.cc +377 -0
  214. data/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.h +102 -0
  215. data/src/core/ext/xds/xds_api.cc +2596 -0
  216. data/src/core/ext/xds/xds_api.h +397 -0
  217. data/src/core/ext/{filters/client_channel/xds → xds}/xds_bootstrap.cc +44 -2
  218. data/src/core/ext/{filters/client_channel/xds → xds}/xds_bootstrap.h +8 -3
  219. data/src/core/ext/{filters/client_channel/xds → xds}/xds_channel_args.h +9 -6
  220. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client.cc +541 -785
  221. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client.h +114 -93
  222. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client_stats.cc +20 -14
  223. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client_stats.h +36 -8
  224. data/src/core/lib/channel/channel_args.h +0 -1
  225. data/src/core/lib/channel/channelz.cc +24 -60
  226. data/src/core/lib/channel/channelz.h +12 -20
  227. data/src/core/lib/channel/channelz_registry.cc +15 -12
  228. data/src/core/lib/channel/channelz_registry.h +3 -0
  229. data/src/core/lib/gpr/sync_posix.cc +2 -8
  230. data/src/core/lib/gpr/time_precise.cc +2 -0
  231. data/src/core/lib/gpr/time_precise.h +6 -2
  232. data/src/core/lib/gprpp/dual_ref_counted.h +336 -0
  233. data/src/core/lib/gprpp/ref_counted.h +51 -22
  234. data/src/core/lib/gprpp/ref_counted_ptr.h +153 -0
  235. data/src/core/lib/iomgr/endpoint.cc +5 -1
  236. data/src/core/lib/iomgr/endpoint.h +7 -3
  237. data/src/core/lib/iomgr/endpoint_cfstream.cc +36 -11
  238. data/src/core/lib/iomgr/ev_posix.cc +0 -2
  239. data/src/core/lib/iomgr/exec_ctx.h +10 -8
  240. data/src/core/lib/iomgr/iomgr.cc +0 -10
  241. data/src/core/lib/iomgr/iomgr.h +0 -10
  242. data/src/core/{ext/filters/client_channel → lib/iomgr}/parse_address.cc +1 -1
  243. data/src/core/{ext/filters/client_channel → lib/iomgr}/parse_address.h +3 -3
  244. data/src/core/lib/iomgr/sockaddr_utils.cc +2 -1
  245. data/src/core/lib/iomgr/sockaddr_utils.h +2 -1
  246. data/src/core/lib/iomgr/tcp_custom.cc +32 -16
  247. data/src/core/lib/iomgr/tcp_posix.cc +31 -13
  248. data/src/core/lib/iomgr/tcp_windows.cc +26 -10
  249. data/src/core/lib/json/json_util.cc +58 -0
  250. data/src/core/lib/json/json_util.h +37 -0
  251. data/src/core/lib/security/authorization/authorization_engine.cc +177 -0
  252. data/src/core/lib/security/authorization/authorization_engine.h +84 -0
  253. data/src/core/lib/security/authorization/evaluate_args.cc +153 -0
  254. data/src/core/lib/security/authorization/evaluate_args.h +59 -0
  255. data/src/core/lib/security/authorization/mock_cel/activation.h +57 -0
  256. data/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +42 -0
  257. data/src/core/lib/security/authorization/mock_cel/cel_expression.h +68 -0
  258. data/src/core/lib/security/authorization/mock_cel/cel_value.h +93 -0
  259. data/src/core/lib/security/authorization/mock_cel/evaluator_core.h +67 -0
  260. data/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +56 -0
  261. data/src/core/lib/security/authorization/mock_cel/statusor.h +50 -0
  262. data/src/core/lib/security/certificate_provider.h +60 -0
  263. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +56 -38
  264. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +321 -0
  265. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +214 -0
  266. data/src/core/lib/security/credentials/xds/xds_credentials.cc +45 -0
  267. data/src/core/lib/security/credentials/xds/xds_credentials.h +51 -0
  268. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +7 -12
  269. data/src/core/lib/security/security_connector/ssl_utils.h +5 -0
  270. data/src/core/lib/security/transport/secure_endpoint.cc +7 -1
  271. data/src/core/lib/surface/call.cc +12 -12
  272. data/src/core/lib/surface/call.h +2 -1
  273. data/src/core/lib/surface/channel.cc +37 -51
  274. data/src/core/lib/surface/channel.h +18 -3
  275. data/src/core/lib/surface/completion_queue.cc +10 -272
  276. data/src/core/lib/surface/completion_queue.h +0 -8
  277. data/src/core/lib/surface/init.cc +27 -12
  278. data/src/core/lib/surface/server.cc +1066 -1244
  279. data/src/core/lib/surface/server.h +363 -87
  280. data/src/core/lib/surface/version.cc +2 -2
  281. data/src/core/lib/transport/authority_override.cc +38 -0
  282. data/src/core/lib/transport/authority_override.h +32 -0
  283. data/src/core/lib/transport/bdp_estimator.h +2 -1
  284. data/src/core/lib/transport/connectivity_state.cc +18 -13
  285. data/src/core/lib/transport/connectivity_state.h +20 -8
  286. data/src/core/lib/transport/error_utils.cc +13 -0
  287. data/src/core/lib/transport/error_utils.h +6 -0
  288. data/src/core/lib/transport/metadata.cc +11 -1
  289. data/src/core/lib/transport/static_metadata.cc +295 -276
  290. data/src/core/lib/transport/static_metadata.h +80 -73
  291. data/src/core/lib/transport/transport.h +7 -0
  292. data/src/core/lib/uri/uri_parser.cc +23 -21
  293. data/src/core/lib/uri/uri_parser.h +3 -1
  294. data/src/core/plugin_registry/grpc_plugin_registry.cc +35 -20
  295. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +22 -0
  296. data/src/core/tsi/ssl_transport_security.cc +2 -2
  297. data/src/ruby/bin/math_services_pb.rb +4 -4
  298. data/src/ruby/ext/grpc/rb_channel_credentials.c +9 -0
  299. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -4
  300. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +7 -7
  301. data/src/ruby/lib/grpc/generic/client_stub.rb +1 -1
  302. data/src/ruby/lib/grpc/version.rb +1 -1
  303. data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +2 -2
  304. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +5 -0
  305. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +28 -12
  306. data/src/ruby/spec/channel_credentials_spec.rb +10 -0
  307. data/src/ruby/spec/generic/active_call_spec.rb +19 -8
  308. data/src/ruby/spec/pb/codegen/grpc/testing/same_package_service_name.proto +27 -0
  309. data/src/ruby/spec/pb/codegen/grpc/testing/same_ruby_package_service_name.proto +29 -0
  310. data/src/ruby/spec/pb/codegen/package_option_spec.rb +20 -0
  311. data/src/ruby/spec/user_agent_spec.rb +74 -0
  312. data/third_party/abseil-cpp/absl/algorithm/container.h +1727 -0
  313. data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +161 -0
  314. data/third_party/abseil-cpp/absl/base/internal/exponential_biased.cc +93 -0
  315. data/third_party/abseil-cpp/absl/base/internal/exponential_biased.h +130 -0
  316. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +620 -0
  317. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +126 -0
  318. data/third_party/abseil-cpp/absl/container/fixed_array.h +515 -0
  319. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +503 -0
  320. data/third_party/abseil-cpp/absl/container/internal/common.h +202 -0
  321. data/third_party/abseil-cpp/absl/container/internal/container_memory.h +440 -0
  322. data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +146 -0
  323. data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +191 -0
  324. data/third_party/abseil-cpp/absl/container/internal/hashtable_debug_hooks.h +85 -0
  325. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +269 -0
  326. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +297 -0
  327. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc +30 -0
  328. data/third_party/abseil-cpp/absl/container/internal/have_sse.h +49 -0
  329. data/third_party/abseil-cpp/absl/container/internal/layout.h +741 -0
  330. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +48 -0
  331. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +1882 -0
  332. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc +138 -0
  333. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.h +32 -0
  334. data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +1895 -0
  335. data/third_party/abseil-cpp/absl/debugging/internal/demangle.h +71 -0
  336. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc +382 -0
  337. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +134 -0
  338. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +192 -0
  339. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc +125 -0
  340. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +70 -0
  341. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +99 -0
  342. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +248 -0
  343. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_unimplemented-inl.inc +24 -0
  344. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +85 -0
  345. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +346 -0
  346. data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +128 -0
  347. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +194 -0
  348. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.h +158 -0
  349. data/third_party/abseil-cpp/absl/debugging/stacktrace.cc +140 -0
  350. data/third_party/abseil-cpp/absl/debugging/stacktrace.h +231 -0
  351. data/third_party/abseil-cpp/absl/debugging/symbolize.cc +25 -0
  352. data/third_party/abseil-cpp/absl/debugging/symbolize.h +99 -0
  353. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +1480 -0
  354. data/third_party/abseil-cpp/absl/debugging/symbolize_unimplemented.inc +40 -0
  355. data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +81 -0
  356. data/third_party/abseil-cpp/absl/functional/function_ref.h +139 -0
  357. data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +106 -0
  358. data/third_party/abseil-cpp/absl/hash/hash.h +324 -0
  359. data/third_party/abseil-cpp/absl/hash/internal/city.cc +346 -0
  360. data/third_party/abseil-cpp/absl/hash/internal/city.h +96 -0
  361. data/third_party/abseil-cpp/absl/hash/internal/hash.cc +55 -0
  362. data/third_party/abseil-cpp/absl/hash/internal/hash.h +988 -0
  363. data/third_party/abseil-cpp/absl/status/status.cc +447 -0
  364. data/third_party/abseil-cpp/absl/status/status.h +428 -0
  365. data/third_party/abseil-cpp/absl/status/status_payload_printer.cc +43 -0
  366. data/third_party/abseil-cpp/absl/status/status_payload_printer.h +51 -0
  367. data/third_party/abseil-cpp/absl/strings/cord.cc +2019 -0
  368. data/third_party/abseil-cpp/absl/strings/cord.h +1121 -0
  369. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +151 -0
  370. data/third_party/abseil-cpp/absl/synchronization/barrier.cc +52 -0
  371. data/third_party/abseil-cpp/absl/synchronization/barrier.h +79 -0
  372. data/third_party/abseil-cpp/absl/synchronization/blocking_counter.cc +57 -0
  373. data/third_party/abseil-cpp/absl/synchronization/blocking_counter.h +99 -0
  374. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +140 -0
  375. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.h +60 -0
  376. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +697 -0
  377. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.h +141 -0
  378. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +155 -0
  379. data/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +261 -0
  380. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +106 -0
  381. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +115 -0
  382. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +484 -0
  383. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +159 -0
  384. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +2728 -0
  385. data/third_party/abseil-cpp/absl/synchronization/mutex.h +1056 -0
  386. data/third_party/abseil-cpp/absl/synchronization/notification.cc +78 -0
  387. data/third_party/abseil-cpp/absl/synchronization/notification.h +123 -0
  388. data/third_party/abseil-cpp/absl/types/bad_variant_access.cc +64 -0
  389. data/third_party/abseil-cpp/absl/types/bad_variant_access.h +82 -0
  390. data/third_party/abseil-cpp/absl/types/internal/variant.h +1646 -0
  391. data/third_party/abseil-cpp/absl/types/variant.h +861 -0
  392. data/third_party/boringssl-with-bazel/err_data.c +475 -467
  393. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +0 -6
  394. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +9 -43
  395. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa_asn1.c +55 -4
  396. data/third_party/boringssl-with-bazel/src/crypto/dsa/internal.h +34 -0
  397. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +4 -0
  398. data/third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.c +16 -0
  399. data/third_party/boringssl-with-bazel/src/crypto/evp/p_dsa_asn1.c +6 -2
  400. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +2 -0
  401. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +4 -0
  402. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +30 -10
  403. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -15
  404. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +543 -0
  405. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +237 -0
  406. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +44 -2
  407. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +221 -49
  408. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +64 -20
  409. data/third_party/boringssl-with-bazel/src/crypto/x509/a_strex.c +3 -3
  410. data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +0 -8
  411. data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +3 -3
  412. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +1 -1
  413. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +7 -2
  414. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +21 -18
  415. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_obj.c +1 -1
  416. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +24 -3
  417. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +3 -3
  418. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_txt.c +67 -67
  419. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +3 -3
  420. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +29 -35
  421. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +13 -2
  422. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +9 -8
  423. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +10 -10
  424. data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +2 -2
  425. data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +28 -40
  426. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +20 -0
  427. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +3 -1
  428. data/third_party/boringssl-with-bazel/src/crypto/x509v3/ext_dat.h +1 -4
  429. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +7 -3
  430. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c +2 -2
  431. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +1 -1
  432. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +55 -8
  433. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +1 -1
  434. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +52 -0
  435. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +0 -1
  436. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +2 -2
  437. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +6 -0
  438. data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +1 -1
  439. data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +12 -0
  440. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +9 -0
  441. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +4 -1
  442. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +48 -9
  443. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +2 -3
  444. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +26 -6
  445. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +199 -78
  446. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +52 -43
  447. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +18 -18
  448. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +2 -3
  449. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +1 -1
  450. data/third_party/boringssl-with-bazel/src/ssl/internal.h +13 -9
  451. data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +3 -6
  452. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +8 -9
  453. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +10 -0
  454. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +34 -9
  455. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +1 -2
  456. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +4 -8
  457. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +7 -2
  458. data/third_party/boringssl-with-bazel/src/ssl/tls_record.cc +5 -3
  459. data/third_party/re2/re2/bitmap256.h +117 -0
  460. data/third_party/re2/re2/bitstate.cc +385 -0
  461. data/third_party/re2/re2/compile.cc +1279 -0
  462. data/third_party/re2/re2/dfa.cc +2130 -0
  463. data/third_party/re2/re2/filtered_re2.cc +121 -0
  464. data/third_party/re2/re2/filtered_re2.h +109 -0
  465. data/third_party/re2/re2/mimics_pcre.cc +197 -0
  466. data/third_party/re2/re2/nfa.cc +713 -0
  467. data/third_party/re2/re2/onepass.cc +623 -0
  468. data/third_party/re2/re2/parse.cc +2464 -0
  469. data/third_party/re2/re2/perl_groups.cc +119 -0
  470. data/third_party/re2/re2/pod_array.h +55 -0
  471. data/third_party/re2/re2/prefilter.cc +710 -0
  472. data/third_party/re2/re2/prefilter.h +108 -0
  473. data/third_party/re2/re2/prefilter_tree.cc +407 -0
  474. data/third_party/re2/re2/prefilter_tree.h +139 -0
  475. data/third_party/re2/re2/prog.cc +988 -0
  476. data/third_party/re2/re2/prog.h +436 -0
  477. data/third_party/re2/re2/re2.cc +1362 -0
  478. data/third_party/re2/re2/re2.h +1002 -0
  479. data/third_party/re2/re2/regexp.cc +980 -0
  480. data/third_party/re2/re2/regexp.h +659 -0
  481. data/third_party/re2/re2/set.cc +154 -0
  482. data/third_party/re2/re2/set.h +80 -0
  483. data/third_party/re2/re2/simplify.cc +657 -0
  484. data/third_party/re2/re2/sparse_array.h +392 -0
  485. data/third_party/re2/re2/sparse_set.h +264 -0
  486. data/third_party/re2/re2/stringpiece.cc +65 -0
  487. data/third_party/re2/re2/stringpiece.h +210 -0
  488. data/third_party/re2/re2/tostring.cc +351 -0
  489. data/third_party/re2/re2/unicode_casefold.cc +582 -0
  490. data/third_party/re2/re2/unicode_casefold.h +78 -0
  491. data/third_party/re2/re2/unicode_groups.cc +6269 -0
  492. data/third_party/re2/re2/unicode_groups.h +67 -0
  493. data/third_party/re2/re2/walker-inl.h +246 -0
  494. data/third_party/re2/util/benchmark.h +156 -0
  495. data/third_party/re2/util/flags.h +26 -0
  496. data/third_party/re2/util/logging.h +109 -0
  497. data/third_party/re2/util/malloc_counter.h +19 -0
  498. data/third_party/re2/util/mix.h +41 -0
  499. data/third_party/re2/util/mutex.h +148 -0
  500. data/third_party/re2/util/pcre.cc +1025 -0
  501. data/third_party/re2/util/pcre.h +681 -0
  502. data/third_party/re2/util/rune.cc +260 -0
  503. data/third_party/re2/util/strutil.cc +149 -0
  504. data/third_party/re2/util/strutil.h +21 -0
  505. data/third_party/re2/util/test.h +50 -0
  506. data/third_party/re2/util/utf.h +44 -0
  507. data/third_party/re2/util/util.h +42 -0
  508. data/third_party/upb/upb/decode.c +64 -15
  509. data/third_party/upb/upb/encode.c +2 -2
  510. data/third_party/upb/upb/msg.h +2 -2
  511. data/third_party/upb/upb/port_def.inc +1 -1
  512. data/third_party/upb/upb/table.c +0 -11
  513. data/third_party/upb/upb/table.int.h +0 -9
  514. data/third_party/upb/upb/upb.c +16 -14
  515. data/third_party/upb/upb/upb.h +26 -0
  516. data/third_party/upb/upb/upb.hpp +2 -0
  517. metadata +340 -153
  518. data/src/core/ext/filters/client_channel/lb_policy/xds/lrs.cc +0 -528
  519. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +0 -1142
  520. data/src/core/ext/filters/client_channel/xds/xds_api.cc +0 -2110
  521. data/src/core/ext/filters/client_channel/xds/xds_api.h +0 -345
  522. data/src/core/ext/filters/client_channel/xds/xds_channel.h +0 -46
  523. data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +0 -106
  524. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +0 -21
  525. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +0 -34
  526. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.c +0 -114
  527. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.h +0 -429
  528. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.c +0 -72
  529. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.h +0 -198
  530. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.c +0 -105
  531. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.h +0 -388
  532. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +0 -52
  533. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.c +0 -403
  534. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.h +0 -1453
  535. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +0 -74
  536. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h +0 -226
  537. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h +0 -69
  538. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +0 -323
  539. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +0 -112
  540. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h +0 -334
  541. data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.h +0 -79
  542. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +0 -313
  543. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +0 -891
  544. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +0 -96
  545. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +0 -328
  546. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.c +0 -34
  547. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.h +0 -71
  548. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +0 -197
  549. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h +0 -649
  550. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +0 -172
  551. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +0 -693
  552. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h +0 -80
  553. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +0 -152
  554. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +0 -536
  555. data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.h +0 -88
  556. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +0 -129
  557. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h +0 -386
  558. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +0 -52
  559. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.c +0 -92
  560. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.h +0 -224
  561. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +0 -18
  562. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h +0 -32
  563. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.c +0 -91
  564. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.h +0 -273
  565. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +0 -112
  566. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h +0 -332
  567. data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.h +0 -52
  568. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.c +0 -109
  569. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.h +0 -415
  570. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.c +0 -18
  571. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.h +0 -32
  572. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.c +0 -145
  573. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.h +0 -538
  574. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.c +0 -43
  575. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.h +0 -111
  576. data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.h +0 -52
  577. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.c +0 -63
  578. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.h +0 -204
  579. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.c +0 -18
  580. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.h +0 -32
  581. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.c +0 -815
  582. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.h +0 -2984
  583. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.c +0 -59
  584. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.h +0 -135
  585. data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.h +0 -52
  586. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.c +0 -228
  587. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.h +0 -732
  588. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.c +0 -316
  589. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.h +0 -1167
  590. data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.h +0 -65
  591. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.c +0 -51
  592. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.h +0 -125
  593. data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h +0 -49
  594. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c +0 -54
  595. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h +0 -136
  596. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.c +0 -63
  597. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.h +0 -145
  598. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.c +0 -53
  599. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.h +0 -133
  600. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.c +0 -88
  601. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.h +0 -258
  602. data/src/core/ext/upb-generated/envoy/type/percent.upb.h +0 -86
  603. data/src/core/ext/upb-generated/envoy/type/range.upb.h +0 -111
  604. data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.h +0 -61
  605. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.c +0 -89
  606. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.h +0 -250
  607. data/src/core/ext/upb-generated/gogoproto/gogo.upb.c +0 -17
  608. data/src/core/ext/upb-generated/gogoproto/gogo.upb.h +0 -29
  609. data/src/core/lib/security/transport/target_authority_table.cc +0 -75
  610. data/src/core/lib/security/transport/target_authority_table.h +0 -40
  611. data/src/core/lib/slice/slice_hash_table.h +0 -199
  612. data/src/core/lib/slice/slice_weak_hash_table.h +0 -102
  613. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pku.c +0 -110
  614. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_sxnet.c +0 -274
@@ -0,0 +1,29 @@
1
+ // Copyright 2020 gRPC authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ syntax = "proto3";
16
+
17
+ package other_name;
18
+
19
+ option ruby_package = "SameName2";
20
+
21
+ service SameName2 {
22
+ rpc Health(Request) returns (Status);
23
+ }
24
+
25
+ message Status {
26
+ string msg = 1;
27
+ }
28
+
29
+ message Request {}
@@ -48,6 +48,26 @@ describe 'Code Generation Options' do
48
48
  expect(services[:NestedMessageTest].output).to eq(RPC::Test::New::Package::Options::Bar::Baz)
49
49
  end
50
50
  end
51
+
52
+ it 'should generate when package and service has same name' do
53
+ with_protos(['grpc/testing/same_package_service_name.proto']) do
54
+ expect { SameName::SameName::Service }.to raise_error(NameError)
55
+ expect(require('grpc/testing/same_package_service_name_services_pb')).to be_truthy
56
+ expect { SameName::SameName::Service }.to_not raise_error
57
+ expect { SameName::Request }.to_not raise_error
58
+ expect { SameName::Status }.to_not raise_error
59
+ end
60
+ end
61
+
62
+ it 'should generate when ruby_package and service has same name' do
63
+ with_protos(['grpc/testing/same_ruby_package_service_name.proto']) do
64
+ expect { SameName2::SameName2::Service }.to raise_error(NameError)
65
+ expect(require('grpc/testing/same_ruby_package_service_name_services_pb')).to be_truthy
66
+ expect { SameName2::SameName2::Service }.to_not raise_error
67
+ expect { SameName2::Request }.to_not raise_error
68
+ expect { SameName2::Status }.to_not raise_error
69
+ end
70
+ end
51
71
  end
52
72
 
53
73
  def with_protos(file_paths)
@@ -0,0 +1,74 @@
1
+ # Copyright 2020 gRPC authors.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'spec_helper'
16
+
17
+ # a test service that checks the cert of its peer
18
+ class UserAgentEchoService
19
+ include GRPC::GenericService
20
+ rpc :an_rpc, EchoMsg, EchoMsg
21
+
22
+ def an_rpc(_req, call)
23
+ EchoMsg.new(msg: call.metadata['user-agent'])
24
+ end
25
+ end
26
+
27
+ UserAgentEchoServiceStub = UserAgentEchoService.rpc_stub_class
28
+
29
+ describe 'user agent' do
30
+ RpcServer = GRPC::RpcServer
31
+
32
+ before(:all) do
33
+ server_opts = {
34
+ poll_period: 1
35
+ }
36
+ @srv = new_rpc_server_for_testing(**server_opts)
37
+ @port = @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
38
+ @srv.handle(UserAgentEchoService)
39
+ @srv_thd = Thread.new { @srv.run }
40
+ @srv.wait_till_running
41
+ end
42
+
43
+ after(:all) do
44
+ expect(@srv.stopped?).to be(false)
45
+ @srv.stop
46
+ @srv_thd.join
47
+ end
48
+
49
+ it 'client sends expected user agent' do
50
+ stub = UserAgentEchoServiceStub.new("localhost:#{@port}",
51
+ :this_channel_is_insecure,
52
+ {})
53
+ response = stub.an_rpc(EchoMsg.new)
54
+ expected_user_agent_prefix = "grpc-ruby/#{GRPC::VERSION}"
55
+ expect(response.msg.start_with?(expected_user_agent_prefix)).to be true
56
+ # check that the expected user agent prefix occurs in the real user agent exactly once
57
+ expect(response.msg.split(expected_user_agent_prefix).size).to eq 2
58
+ end
59
+
60
+ it 'user agent header does not grow when the same channel args hash is used across multiple stubs' do
61
+ shared_channel_args_hash = {}
62
+ 10.times do
63
+ stub = UserAgentEchoServiceStub.new("localhost:#{@port}",
64
+ :this_channel_is_insecure,
65
+ channel_args: shared_channel_args_hash)
66
+ response = stub.an_rpc(EchoMsg.new)
67
+ puts "got echo response: #{response.msg}"
68
+ expected_user_agent_prefix = "grpc-ruby/#{GRPC::VERSION}"
69
+ expect(response.msg.start_with?(expected_user_agent_prefix)).to be true
70
+ # check that the expected user agent prefix occurs in the real user agent exactly once
71
+ expect(response.msg.split(expected_user_agent_prefix).size).to eq 2
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,1727 @@
1
+ // Copyright 2017 The Abseil Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // https://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ // -----------------------------------------------------------------------------
16
+ // File: container.h
17
+ // -----------------------------------------------------------------------------
18
+ //
19
+ // This header file provides Container-based versions of algorithmic functions
20
+ // within the C++ standard library. The following standard library sets of
21
+ // functions are covered within this file:
22
+ //
23
+ // * Algorithmic <iterator> functions
24
+ // * Algorithmic <numeric> functions
25
+ // * <algorithm> functions
26
+ //
27
+ // The standard library functions operate on iterator ranges; the functions
28
+ // within this API operate on containers, though many return iterator ranges.
29
+ //
30
+ // All functions within this API are named with a `c_` prefix. Calls such as
31
+ // `absl::c_xx(container, ...) are equivalent to std:: functions such as
32
+ // `std::xx(std::begin(cont), std::end(cont), ...)`. Functions that act on
33
+ // iterators but not conceptually on iterator ranges (e.g. `std::iter_swap`)
34
+ // have no equivalent here.
35
+ //
36
+ // For template parameter and variable naming, `C` indicates the container type
37
+ // to which the function is applied, `Pred` indicates the predicate object type
38
+ // to be used by the function and `T` indicates the applicable element type.
39
+
40
+ #ifndef ABSL_ALGORITHM_CONTAINER_H_
41
+ #define ABSL_ALGORITHM_CONTAINER_H_
42
+
43
+ #include <algorithm>
44
+ #include <cassert>
45
+ #include <iterator>
46
+ #include <numeric>
47
+ #include <type_traits>
48
+ #include <unordered_map>
49
+ #include <unordered_set>
50
+ #include <utility>
51
+ #include <vector>
52
+
53
+ #include "absl/algorithm/algorithm.h"
54
+ #include "absl/base/macros.h"
55
+ #include "absl/meta/type_traits.h"
56
+
57
+ namespace absl {
58
+ ABSL_NAMESPACE_BEGIN
59
+ namespace container_algorithm_internal {
60
+
61
+ // NOTE: it is important to defer to ADL lookup for building with C++ modules,
62
+ // especially for headers like <valarray> which are not visible from this file
63
+ // but specialize std::begin and std::end.
64
+ using std::begin;
65
+ using std::end;
66
+
67
+ // The type of the iterator given by begin(c) (possibly std::begin(c)).
68
+ // ContainerIter<const vector<T>> gives vector<T>::const_iterator,
69
+ // while ContainerIter<vector<T>> gives vector<T>::iterator.
70
+ template <typename C>
71
+ using ContainerIter = decltype(begin(std::declval<C&>()));
72
+
73
+ // An MSVC bug involving template parameter substitution requires us to use
74
+ // decltype() here instead of just std::pair.
75
+ template <typename C1, typename C2>
76
+ using ContainerIterPairType =
77
+ decltype(std::make_pair(ContainerIter<C1>(), ContainerIter<C2>()));
78
+
79
+ template <typename C>
80
+ using ContainerDifferenceType =
81
+ decltype(std::distance(std::declval<ContainerIter<C>>(),
82
+ std::declval<ContainerIter<C>>()));
83
+
84
+ template <typename C>
85
+ using ContainerPointerType =
86
+ typename std::iterator_traits<ContainerIter<C>>::pointer;
87
+
88
+ // container_algorithm_internal::c_begin and
89
+ // container_algorithm_internal::c_end are abbreviations for proper ADL
90
+ // lookup of std::begin and std::end, i.e.
91
+ // using std::begin;
92
+ // using std::end;
93
+ // std::foo(begin(c), end(c);
94
+ // becomes
95
+ // std::foo(container_algorithm_internal::begin(c),
96
+ // container_algorithm_internal::end(c));
97
+ // These are meant for internal use only.
98
+
99
+ template <typename C>
100
+ ContainerIter<C> c_begin(C& c) { return begin(c); }
101
+
102
+ template <typename C>
103
+ ContainerIter<C> c_end(C& c) { return end(c); }
104
+
105
+ template <typename T>
106
+ struct IsUnorderedContainer : std::false_type {};
107
+
108
+ template <class Key, class T, class Hash, class KeyEqual, class Allocator>
109
+ struct IsUnorderedContainer<
110
+ std::unordered_map<Key, T, Hash, KeyEqual, Allocator>> : std::true_type {};
111
+
112
+ template <class Key, class Hash, class KeyEqual, class Allocator>
113
+ struct IsUnorderedContainer<std::unordered_set<Key, Hash, KeyEqual, Allocator>>
114
+ : std::true_type {};
115
+
116
+ // container_algorithm_internal::c_size. It is meant for internal use only.
117
+
118
+ template <class C>
119
+ auto c_size(C& c) -> decltype(c.size()) {
120
+ return c.size();
121
+ }
122
+
123
+ template <class T, std::size_t N>
124
+ constexpr std::size_t c_size(T (&)[N]) {
125
+ return N;
126
+ }
127
+
128
+ } // namespace container_algorithm_internal
129
+
130
+ // PUBLIC API
131
+
132
+ //------------------------------------------------------------------------------
133
+ // Abseil algorithm.h functions
134
+ //------------------------------------------------------------------------------
135
+
136
+ // c_linear_search()
137
+ //
138
+ // Container-based version of absl::linear_search() for performing a linear
139
+ // search within a container.
140
+ template <typename C, typename EqualityComparable>
141
+ bool c_linear_search(const C& c, EqualityComparable&& value) {
142
+ return linear_search(container_algorithm_internal::c_begin(c),
143
+ container_algorithm_internal::c_end(c),
144
+ std::forward<EqualityComparable>(value));
145
+ }
146
+
147
+ //------------------------------------------------------------------------------
148
+ // <iterator> algorithms
149
+ //------------------------------------------------------------------------------
150
+
151
+ // c_distance()
152
+ //
153
+ // Container-based version of the <iterator> `std::distance()` function to
154
+ // return the number of elements within a container.
155
+ template <typename C>
156
+ container_algorithm_internal::ContainerDifferenceType<const C> c_distance(
157
+ const C& c) {
158
+ return std::distance(container_algorithm_internal::c_begin(c),
159
+ container_algorithm_internal::c_end(c));
160
+ }
161
+
162
+ //------------------------------------------------------------------------------
163
+ // <algorithm> Non-modifying sequence operations
164
+ //------------------------------------------------------------------------------
165
+
166
+ // c_all_of()
167
+ //
168
+ // Container-based version of the <algorithm> `std::all_of()` function to
169
+ // test a condition on all elements within a container.
170
+ template <typename C, typename Pred>
171
+ bool c_all_of(const C& c, Pred&& pred) {
172
+ return std::all_of(container_algorithm_internal::c_begin(c),
173
+ container_algorithm_internal::c_end(c),
174
+ std::forward<Pred>(pred));
175
+ }
176
+
177
+ // c_any_of()
178
+ //
179
+ // Container-based version of the <algorithm> `std::any_of()` function to
180
+ // test if any element in a container fulfills a condition.
181
+ template <typename C, typename Pred>
182
+ bool c_any_of(const C& c, Pred&& pred) {
183
+ return std::any_of(container_algorithm_internal::c_begin(c),
184
+ container_algorithm_internal::c_end(c),
185
+ std::forward<Pred>(pred));
186
+ }
187
+
188
+ // c_none_of()
189
+ //
190
+ // Container-based version of the <algorithm> `std::none_of()` function to
191
+ // test if no elements in a container fulfil a condition.
192
+ template <typename C, typename Pred>
193
+ bool c_none_of(const C& c, Pred&& pred) {
194
+ return std::none_of(container_algorithm_internal::c_begin(c),
195
+ container_algorithm_internal::c_end(c),
196
+ std::forward<Pred>(pred));
197
+ }
198
+
199
+ // c_for_each()
200
+ //
201
+ // Container-based version of the <algorithm> `std::for_each()` function to
202
+ // apply a function to a container's elements.
203
+ template <typename C, typename Function>
204
+ decay_t<Function> c_for_each(C&& c, Function&& f) {
205
+ return std::for_each(container_algorithm_internal::c_begin(c),
206
+ container_algorithm_internal::c_end(c),
207
+ std::forward<Function>(f));
208
+ }
209
+
210
+ // c_find()
211
+ //
212
+ // Container-based version of the <algorithm> `std::find()` function to find
213
+ // the first element containing the passed value within a container value.
214
+ template <typename C, typename T>
215
+ container_algorithm_internal::ContainerIter<C> c_find(C& c, T&& value) {
216
+ return std::find(container_algorithm_internal::c_begin(c),
217
+ container_algorithm_internal::c_end(c),
218
+ std::forward<T>(value));
219
+ }
220
+
221
+ // c_find_if()
222
+ //
223
+ // Container-based version of the <algorithm> `std::find_if()` function to find
224
+ // the first element in a container matching the given condition.
225
+ template <typename C, typename Pred>
226
+ container_algorithm_internal::ContainerIter<C> c_find_if(C& c, Pred&& pred) {
227
+ return std::find_if(container_algorithm_internal::c_begin(c),
228
+ container_algorithm_internal::c_end(c),
229
+ std::forward<Pred>(pred));
230
+ }
231
+
232
+ // c_find_if_not()
233
+ //
234
+ // Container-based version of the <algorithm> `std::find_if_not()` function to
235
+ // find the first element in a container not matching the given condition.
236
+ template <typename C, typename Pred>
237
+ container_algorithm_internal::ContainerIter<C> c_find_if_not(C& c,
238
+ Pred&& pred) {
239
+ return std::find_if_not(container_algorithm_internal::c_begin(c),
240
+ container_algorithm_internal::c_end(c),
241
+ std::forward<Pred>(pred));
242
+ }
243
+
244
+ // c_find_end()
245
+ //
246
+ // Container-based version of the <algorithm> `std::find_end()` function to
247
+ // find the last subsequence within a container.
248
+ template <typename Sequence1, typename Sequence2>
249
+ container_algorithm_internal::ContainerIter<Sequence1> c_find_end(
250
+ Sequence1& sequence, Sequence2& subsequence) {
251
+ return std::find_end(container_algorithm_internal::c_begin(sequence),
252
+ container_algorithm_internal::c_end(sequence),
253
+ container_algorithm_internal::c_begin(subsequence),
254
+ container_algorithm_internal::c_end(subsequence));
255
+ }
256
+
257
+ // Overload of c_find_end() for using a predicate evaluation other than `==` as
258
+ // the function's test condition.
259
+ template <typename Sequence1, typename Sequence2, typename BinaryPredicate>
260
+ container_algorithm_internal::ContainerIter<Sequence1> c_find_end(
261
+ Sequence1& sequence, Sequence2& subsequence, BinaryPredicate&& pred) {
262
+ return std::find_end(container_algorithm_internal::c_begin(sequence),
263
+ container_algorithm_internal::c_end(sequence),
264
+ container_algorithm_internal::c_begin(subsequence),
265
+ container_algorithm_internal::c_end(subsequence),
266
+ std::forward<BinaryPredicate>(pred));
267
+ }
268
+
269
+ // c_find_first_of()
270
+ //
271
+ // Container-based version of the <algorithm> `std::find_first_of()` function to
272
+ // find the first element within the container that is also within the options
273
+ // container.
274
+ template <typename C1, typename C2>
275
+ container_algorithm_internal::ContainerIter<C1> c_find_first_of(C1& container,
276
+ C2& options) {
277
+ return std::find_first_of(container_algorithm_internal::c_begin(container),
278
+ container_algorithm_internal::c_end(container),
279
+ container_algorithm_internal::c_begin(options),
280
+ container_algorithm_internal::c_end(options));
281
+ }
282
+
283
+ // Overload of c_find_first_of() for using a predicate evaluation other than
284
+ // `==` as the function's test condition.
285
+ template <typename C1, typename C2, typename BinaryPredicate>
286
+ container_algorithm_internal::ContainerIter<C1> c_find_first_of(
287
+ C1& container, C2& options, BinaryPredicate&& pred) {
288
+ return std::find_first_of(container_algorithm_internal::c_begin(container),
289
+ container_algorithm_internal::c_end(container),
290
+ container_algorithm_internal::c_begin(options),
291
+ container_algorithm_internal::c_end(options),
292
+ std::forward<BinaryPredicate>(pred));
293
+ }
294
+
295
+ // c_adjacent_find()
296
+ //
297
+ // Container-based version of the <algorithm> `std::adjacent_find()` function to
298
+ // find equal adjacent elements within a container.
299
+ template <typename Sequence>
300
+ container_algorithm_internal::ContainerIter<Sequence> c_adjacent_find(
301
+ Sequence& sequence) {
302
+ return std::adjacent_find(container_algorithm_internal::c_begin(sequence),
303
+ container_algorithm_internal::c_end(sequence));
304
+ }
305
+
306
+ // Overload of c_adjacent_find() for using a predicate evaluation other than
307
+ // `==` as the function's test condition.
308
+ template <typename Sequence, typename BinaryPredicate>
309
+ container_algorithm_internal::ContainerIter<Sequence> c_adjacent_find(
310
+ Sequence& sequence, BinaryPredicate&& pred) {
311
+ return std::adjacent_find(container_algorithm_internal::c_begin(sequence),
312
+ container_algorithm_internal::c_end(sequence),
313
+ std::forward<BinaryPredicate>(pred));
314
+ }
315
+
316
+ // c_count()
317
+ //
318
+ // Container-based version of the <algorithm> `std::count()` function to count
319
+ // values that match within a container.
320
+ template <typename C, typename T>
321
+ container_algorithm_internal::ContainerDifferenceType<const C> c_count(
322
+ const C& c, T&& value) {
323
+ return std::count(container_algorithm_internal::c_begin(c),
324
+ container_algorithm_internal::c_end(c),
325
+ std::forward<T>(value));
326
+ }
327
+
328
+ // c_count_if()
329
+ //
330
+ // Container-based version of the <algorithm> `std::count_if()` function to
331
+ // count values matching a condition within a container.
332
+ template <typename C, typename Pred>
333
+ container_algorithm_internal::ContainerDifferenceType<const C> c_count_if(
334
+ const C& c, Pred&& pred) {
335
+ return std::count_if(container_algorithm_internal::c_begin(c),
336
+ container_algorithm_internal::c_end(c),
337
+ std::forward<Pred>(pred));
338
+ }
339
+
340
+ // c_mismatch()
341
+ //
342
+ // Container-based version of the <algorithm> `std::mismatch()` function to
343
+ // return the first element where two ordered containers differ.
344
+ template <typename C1, typename C2>
345
+ container_algorithm_internal::ContainerIterPairType<C1, C2>
346
+ c_mismatch(C1& c1, C2& c2) {
347
+ return std::mismatch(container_algorithm_internal::c_begin(c1),
348
+ container_algorithm_internal::c_end(c1),
349
+ container_algorithm_internal::c_begin(c2));
350
+ }
351
+
352
+ // Overload of c_mismatch() for using a predicate evaluation other than `==` as
353
+ // the function's test condition.
354
+ template <typename C1, typename C2, typename BinaryPredicate>
355
+ container_algorithm_internal::ContainerIterPairType<C1, C2>
356
+ c_mismatch(C1& c1, C2& c2, BinaryPredicate&& pred) {
357
+ return std::mismatch(container_algorithm_internal::c_begin(c1),
358
+ container_algorithm_internal::c_end(c1),
359
+ container_algorithm_internal::c_begin(c2),
360
+ std::forward<BinaryPredicate>(pred));
361
+ }
362
+
363
+ // c_equal()
364
+ //
365
+ // Container-based version of the <algorithm> `std::equal()` function to
366
+ // test whether two containers are equal.
367
+ //
368
+ // NOTE: the semantics of c_equal() are slightly different than those of
369
+ // equal(): while the latter iterates over the second container only up to the
370
+ // size of the first container, c_equal() also checks whether the container
371
+ // sizes are equal. This better matches expectations about c_equal() based on
372
+ // its signature.
373
+ //
374
+ // Example:
375
+ // vector v1 = <1, 2, 3>;
376
+ // vector v2 = <1, 2, 3, 4>;
377
+ // equal(std::begin(v1), std::end(v1), std::begin(v2)) returns true
378
+ // c_equal(v1, v2) returns false
379
+
380
+ template <typename C1, typename C2>
381
+ bool c_equal(const C1& c1, const C2& c2) {
382
+ return ((container_algorithm_internal::c_size(c1) ==
383
+ container_algorithm_internal::c_size(c2)) &&
384
+ std::equal(container_algorithm_internal::c_begin(c1),
385
+ container_algorithm_internal::c_end(c1),
386
+ container_algorithm_internal::c_begin(c2)));
387
+ }
388
+
389
+ // Overload of c_equal() for using a predicate evaluation other than `==` as
390
+ // the function's test condition.
391
+ template <typename C1, typename C2, typename BinaryPredicate>
392
+ bool c_equal(const C1& c1, const C2& c2, BinaryPredicate&& pred) {
393
+ return ((container_algorithm_internal::c_size(c1) ==
394
+ container_algorithm_internal::c_size(c2)) &&
395
+ std::equal(container_algorithm_internal::c_begin(c1),
396
+ container_algorithm_internal::c_end(c1),
397
+ container_algorithm_internal::c_begin(c2),
398
+ std::forward<BinaryPredicate>(pred)));
399
+ }
400
+
401
+ // c_is_permutation()
402
+ //
403
+ // Container-based version of the <algorithm> `std::is_permutation()` function
404
+ // to test whether a container is a permutation of another.
405
+ template <typename C1, typename C2>
406
+ bool c_is_permutation(const C1& c1, const C2& c2) {
407
+ using std::begin;
408
+ using std::end;
409
+ return c1.size() == c2.size() &&
410
+ std::is_permutation(begin(c1), end(c1), begin(c2));
411
+ }
412
+
413
+ // Overload of c_is_permutation() for using a predicate evaluation other than
414
+ // `==` as the function's test condition.
415
+ template <typename C1, typename C2, typename BinaryPredicate>
416
+ bool c_is_permutation(const C1& c1, const C2& c2, BinaryPredicate&& pred) {
417
+ using std::begin;
418
+ using std::end;
419
+ return c1.size() == c2.size() &&
420
+ std::is_permutation(begin(c1), end(c1), begin(c2),
421
+ std::forward<BinaryPredicate>(pred));
422
+ }
423
+
424
+ // c_search()
425
+ //
426
+ // Container-based version of the <algorithm> `std::search()` function to search
427
+ // a container for a subsequence.
428
+ template <typename Sequence1, typename Sequence2>
429
+ container_algorithm_internal::ContainerIter<Sequence1> c_search(
430
+ Sequence1& sequence, Sequence2& subsequence) {
431
+ return std::search(container_algorithm_internal::c_begin(sequence),
432
+ container_algorithm_internal::c_end(sequence),
433
+ container_algorithm_internal::c_begin(subsequence),
434
+ container_algorithm_internal::c_end(subsequence));
435
+ }
436
+
437
+ // Overload of c_search() for using a predicate evaluation other than
438
+ // `==` as the function's test condition.
439
+ template <typename Sequence1, typename Sequence2, typename BinaryPredicate>
440
+ container_algorithm_internal::ContainerIter<Sequence1> c_search(
441
+ Sequence1& sequence, Sequence2& subsequence, BinaryPredicate&& pred) {
442
+ return std::search(container_algorithm_internal::c_begin(sequence),
443
+ container_algorithm_internal::c_end(sequence),
444
+ container_algorithm_internal::c_begin(subsequence),
445
+ container_algorithm_internal::c_end(subsequence),
446
+ std::forward<BinaryPredicate>(pred));
447
+ }
448
+
449
+ // c_search_n()
450
+ //
451
+ // Container-based version of the <algorithm> `std::search_n()` function to
452
+ // search a container for the first sequence of N elements.
453
+ template <typename Sequence, typename Size, typename T>
454
+ container_algorithm_internal::ContainerIter<Sequence> c_search_n(
455
+ Sequence& sequence, Size count, T&& value) {
456
+ return std::search_n(container_algorithm_internal::c_begin(sequence),
457
+ container_algorithm_internal::c_end(sequence), count,
458
+ std::forward<T>(value));
459
+ }
460
+
461
+ // Overload of c_search_n() for using a predicate evaluation other than
462
+ // `==` as the function's test condition.
463
+ template <typename Sequence, typename Size, typename T,
464
+ typename BinaryPredicate>
465
+ container_algorithm_internal::ContainerIter<Sequence> c_search_n(
466
+ Sequence& sequence, Size count, T&& value, BinaryPredicate&& pred) {
467
+ return std::search_n(container_algorithm_internal::c_begin(sequence),
468
+ container_algorithm_internal::c_end(sequence), count,
469
+ std::forward<T>(value),
470
+ std::forward<BinaryPredicate>(pred));
471
+ }
472
+
473
+ //------------------------------------------------------------------------------
474
+ // <algorithm> Modifying sequence operations
475
+ //------------------------------------------------------------------------------
476
+
477
+ // c_copy()
478
+ //
479
+ // Container-based version of the <algorithm> `std::copy()` function to copy a
480
+ // container's elements into an iterator.
481
+ template <typename InputSequence, typename OutputIterator>
482
+ OutputIterator c_copy(const InputSequence& input, OutputIterator output) {
483
+ return std::copy(container_algorithm_internal::c_begin(input),
484
+ container_algorithm_internal::c_end(input), output);
485
+ }
486
+
487
+ // c_copy_n()
488
+ //
489
+ // Container-based version of the <algorithm> `std::copy_n()` function to copy a
490
+ // container's first N elements into an iterator.
491
+ template <typename C, typename Size, typename OutputIterator>
492
+ OutputIterator c_copy_n(const C& input, Size n, OutputIterator output) {
493
+ return std::copy_n(container_algorithm_internal::c_begin(input), n, output);
494
+ }
495
+
496
+ // c_copy_if()
497
+ //
498
+ // Container-based version of the <algorithm> `std::copy_if()` function to copy
499
+ // a container's elements satisfying some condition into an iterator.
500
+ template <typename InputSequence, typename OutputIterator, typename Pred>
501
+ OutputIterator c_copy_if(const InputSequence& input, OutputIterator output,
502
+ Pred&& pred) {
503
+ return std::copy_if(container_algorithm_internal::c_begin(input),
504
+ container_algorithm_internal::c_end(input), output,
505
+ std::forward<Pred>(pred));
506
+ }
507
+
508
+ // c_copy_backward()
509
+ //
510
+ // Container-based version of the <algorithm> `std::copy_backward()` function to
511
+ // copy a container's elements in reverse order into an iterator.
512
+ template <typename C, typename BidirectionalIterator>
513
+ BidirectionalIterator c_copy_backward(const C& src,
514
+ BidirectionalIterator dest) {
515
+ return std::copy_backward(container_algorithm_internal::c_begin(src),
516
+ container_algorithm_internal::c_end(src), dest);
517
+ }
518
+
519
+ // c_move()
520
+ //
521
+ // Container-based version of the <algorithm> `std::move()` function to move
522
+ // a container's elements into an iterator.
523
+ template <typename C, typename OutputIterator>
524
+ OutputIterator c_move(C&& src, OutputIterator dest) {
525
+ return std::move(container_algorithm_internal::c_begin(src),
526
+ container_algorithm_internal::c_end(src), dest);
527
+ }
528
+
529
+ // c_move_backward()
530
+ //
531
+ // Container-based version of the <algorithm> `std::move_backward()` function to
532
+ // move a container's elements into an iterator in reverse order.
533
+ template <typename C, typename BidirectionalIterator>
534
+ BidirectionalIterator c_move_backward(C&& src, BidirectionalIterator dest) {
535
+ return std::move_backward(container_algorithm_internal::c_begin(src),
536
+ container_algorithm_internal::c_end(src), dest);
537
+ }
538
+
539
+ // c_swap_ranges()
540
+ //
541
+ // Container-based version of the <algorithm> `std::swap_ranges()` function to
542
+ // swap a container's elements with another container's elements.
543
+ template <typename C1, typename C2>
544
+ container_algorithm_internal::ContainerIter<C2> c_swap_ranges(C1& c1, C2& c2) {
545
+ return std::swap_ranges(container_algorithm_internal::c_begin(c1),
546
+ container_algorithm_internal::c_end(c1),
547
+ container_algorithm_internal::c_begin(c2));
548
+ }
549
+
550
+ // c_transform()
551
+ //
552
+ // Container-based version of the <algorithm> `std::transform()` function to
553
+ // transform a container's elements using the unary operation, storing the
554
+ // result in an iterator pointing to the last transformed element in the output
555
+ // range.
556
+ template <typename InputSequence, typename OutputIterator, typename UnaryOp>
557
+ OutputIterator c_transform(const InputSequence& input, OutputIterator output,
558
+ UnaryOp&& unary_op) {
559
+ return std::transform(container_algorithm_internal::c_begin(input),
560
+ container_algorithm_internal::c_end(input), output,
561
+ std::forward<UnaryOp>(unary_op));
562
+ }
563
+
564
+ // Overload of c_transform() for performing a transformation using a binary
565
+ // predicate.
566
+ template <typename InputSequence1, typename InputSequence2,
567
+ typename OutputIterator, typename BinaryOp>
568
+ OutputIterator c_transform(const InputSequence1& input1,
569
+ const InputSequence2& input2, OutputIterator output,
570
+ BinaryOp&& binary_op) {
571
+ return std::transform(container_algorithm_internal::c_begin(input1),
572
+ container_algorithm_internal::c_end(input1),
573
+ container_algorithm_internal::c_begin(input2), output,
574
+ std::forward<BinaryOp>(binary_op));
575
+ }
576
+
577
+ // c_replace()
578
+ //
579
+ // Container-based version of the <algorithm> `std::replace()` function to
580
+ // replace a container's elements of some value with a new value. The container
581
+ // is modified in place.
582
+ template <typename Sequence, typename T>
583
+ void c_replace(Sequence& sequence, const T& old_value, const T& new_value) {
584
+ std::replace(container_algorithm_internal::c_begin(sequence),
585
+ container_algorithm_internal::c_end(sequence), old_value,
586
+ new_value);
587
+ }
588
+
589
+ // c_replace_if()
590
+ //
591
+ // Container-based version of the <algorithm> `std::replace_if()` function to
592
+ // replace a container's elements of some value with a new value based on some
593
+ // condition. The container is modified in place.
594
+ template <typename C, typename Pred, typename T>
595
+ void c_replace_if(C& c, Pred&& pred, T&& new_value) {
596
+ std::replace_if(container_algorithm_internal::c_begin(c),
597
+ container_algorithm_internal::c_end(c),
598
+ std::forward<Pred>(pred), std::forward<T>(new_value));
599
+ }
600
+
601
+ // c_replace_copy()
602
+ //
603
+ // Container-based version of the <algorithm> `std::replace_copy()` function to
604
+ // replace a container's elements of some value with a new value and return the
605
+ // results within an iterator.
606
+ template <typename C, typename OutputIterator, typename T>
607
+ OutputIterator c_replace_copy(const C& c, OutputIterator result, T&& old_value,
608
+ T&& new_value) {
609
+ return std::replace_copy(container_algorithm_internal::c_begin(c),
610
+ container_algorithm_internal::c_end(c), result,
611
+ std::forward<T>(old_value),
612
+ std::forward<T>(new_value));
613
+ }
614
+
615
+ // c_replace_copy_if()
616
+ //
617
+ // Container-based version of the <algorithm> `std::replace_copy_if()` function
618
+ // to replace a container's elements of some value with a new value based on
619
+ // some condition, and return the results within an iterator.
620
+ template <typename C, typename OutputIterator, typename Pred, typename T>
621
+ OutputIterator c_replace_copy_if(const C& c, OutputIterator result, Pred&& pred,
622
+ T&& new_value) {
623
+ return std::replace_copy_if(container_algorithm_internal::c_begin(c),
624
+ container_algorithm_internal::c_end(c), result,
625
+ std::forward<Pred>(pred),
626
+ std::forward<T>(new_value));
627
+ }
628
+
629
+ // c_fill()
630
+ //
631
+ // Container-based version of the <algorithm> `std::fill()` function to fill a
632
+ // container with some value.
633
+ template <typename C, typename T>
634
+ void c_fill(C& c, T&& value) {
635
+ std::fill(container_algorithm_internal::c_begin(c),
636
+ container_algorithm_internal::c_end(c), std::forward<T>(value));
637
+ }
638
+
639
+ // c_fill_n()
640
+ //
641
+ // Container-based version of the <algorithm> `std::fill_n()` function to fill
642
+ // the first N elements in a container with some value.
643
+ template <typename C, typename Size, typename T>
644
+ void c_fill_n(C& c, Size n, T&& value) {
645
+ std::fill_n(container_algorithm_internal::c_begin(c), n,
646
+ std::forward<T>(value));
647
+ }
648
+
649
+ // c_generate()
650
+ //
651
+ // Container-based version of the <algorithm> `std::generate()` function to
652
+ // assign a container's elements to the values provided by the given generator.
653
+ template <typename C, typename Generator>
654
+ void c_generate(C& c, Generator&& gen) {
655
+ std::generate(container_algorithm_internal::c_begin(c),
656
+ container_algorithm_internal::c_end(c),
657
+ std::forward<Generator>(gen));
658
+ }
659
+
660
+ // c_generate_n()
661
+ //
662
+ // Container-based version of the <algorithm> `std::generate_n()` function to
663
+ // assign a container's first N elements to the values provided by the given
664
+ // generator.
665
+ template <typename C, typename Size, typename Generator>
666
+ container_algorithm_internal::ContainerIter<C> c_generate_n(C& c, Size n,
667
+ Generator&& gen) {
668
+ return std::generate_n(container_algorithm_internal::c_begin(c), n,
669
+ std::forward<Generator>(gen));
670
+ }
671
+
672
+ // Note: `c_xx()` <algorithm> container versions for `remove()`, `remove_if()`,
673
+ // and `unique()` are omitted, because it's not clear whether or not such
674
+ // functions should call erase on their supplied sequences afterwards. Either
675
+ // behavior would be surprising for a different set of users.
676
+
677
+ // c_remove_copy()
678
+ //
679
+ // Container-based version of the <algorithm> `std::remove_copy()` function to
680
+ // copy a container's elements while removing any elements matching the given
681
+ // `value`.
682
+ template <typename C, typename OutputIterator, typename T>
683
+ OutputIterator c_remove_copy(const C& c, OutputIterator result, T&& value) {
684
+ return std::remove_copy(container_algorithm_internal::c_begin(c),
685
+ container_algorithm_internal::c_end(c), result,
686
+ std::forward<T>(value));
687
+ }
688
+
689
+ // c_remove_copy_if()
690
+ //
691
+ // Container-based version of the <algorithm> `std::remove_copy_if()` function
692
+ // to copy a container's elements while removing any elements matching the given
693
+ // condition.
694
+ template <typename C, typename OutputIterator, typename Pred>
695
+ OutputIterator c_remove_copy_if(const C& c, OutputIterator result,
696
+ Pred&& pred) {
697
+ return std::remove_copy_if(container_algorithm_internal::c_begin(c),
698
+ container_algorithm_internal::c_end(c), result,
699
+ std::forward<Pred>(pred));
700
+ }
701
+
702
+ // c_unique_copy()
703
+ //
704
+ // Container-based version of the <algorithm> `std::unique_copy()` function to
705
+ // copy a container's elements while removing any elements containing duplicate
706
+ // values.
707
+ template <typename C, typename OutputIterator>
708
+ OutputIterator c_unique_copy(const C& c, OutputIterator result) {
709
+ return std::unique_copy(container_algorithm_internal::c_begin(c),
710
+ container_algorithm_internal::c_end(c), result);
711
+ }
712
+
713
+ // Overload of c_unique_copy() for using a predicate evaluation other than
714
+ // `==` for comparing uniqueness of the element values.
715
+ template <typename C, typename OutputIterator, typename BinaryPredicate>
716
+ OutputIterator c_unique_copy(const C& c, OutputIterator result,
717
+ BinaryPredicate&& pred) {
718
+ return std::unique_copy(container_algorithm_internal::c_begin(c),
719
+ container_algorithm_internal::c_end(c), result,
720
+ std::forward<BinaryPredicate>(pred));
721
+ }
722
+
723
+ // c_reverse()
724
+ //
725
+ // Container-based version of the <algorithm> `std::reverse()` function to
726
+ // reverse a container's elements.
727
+ template <typename Sequence>
728
+ void c_reverse(Sequence& sequence) {
729
+ std::reverse(container_algorithm_internal::c_begin(sequence),
730
+ container_algorithm_internal::c_end(sequence));
731
+ }
732
+
733
+ // c_reverse_copy()
734
+ //
735
+ // Container-based version of the <algorithm> `std::reverse()` function to
736
+ // reverse a container's elements and write them to an iterator range.
737
+ template <typename C, typename OutputIterator>
738
+ OutputIterator c_reverse_copy(const C& sequence, OutputIterator result) {
739
+ return std::reverse_copy(container_algorithm_internal::c_begin(sequence),
740
+ container_algorithm_internal::c_end(sequence),
741
+ result);
742
+ }
743
+
744
+ // c_rotate()
745
+ //
746
+ // Container-based version of the <algorithm> `std::rotate()` function to
747
+ // shift a container's elements leftward such that the `middle` element becomes
748
+ // the first element in the container.
749
+ template <typename C,
750
+ typename Iterator = container_algorithm_internal::ContainerIter<C>>
751
+ Iterator c_rotate(C& sequence, Iterator middle) {
752
+ return absl::rotate(container_algorithm_internal::c_begin(sequence), middle,
753
+ container_algorithm_internal::c_end(sequence));
754
+ }
755
+
756
+ // c_rotate_copy()
757
+ //
758
+ // Container-based version of the <algorithm> `std::rotate_copy()` function to
759
+ // shift a container's elements leftward such that the `middle` element becomes
760
+ // the first element in a new iterator range.
761
+ template <typename C, typename OutputIterator>
762
+ OutputIterator c_rotate_copy(
763
+ const C& sequence,
764
+ container_algorithm_internal::ContainerIter<const C> middle,
765
+ OutputIterator result) {
766
+ return std::rotate_copy(container_algorithm_internal::c_begin(sequence),
767
+ middle, container_algorithm_internal::c_end(sequence),
768
+ result);
769
+ }
770
+
771
+ // c_shuffle()
772
+ //
773
+ // Container-based version of the <algorithm> `std::shuffle()` function to
774
+ // randomly shuffle elements within the container using a `gen()` uniform random
775
+ // number generator.
776
+ template <typename RandomAccessContainer, typename UniformRandomBitGenerator>
777
+ void c_shuffle(RandomAccessContainer& c, UniformRandomBitGenerator&& gen) {
778
+ std::shuffle(container_algorithm_internal::c_begin(c),
779
+ container_algorithm_internal::c_end(c),
780
+ std::forward<UniformRandomBitGenerator>(gen));
781
+ }
782
+
783
+ //------------------------------------------------------------------------------
784
+ // <algorithm> Partition functions
785
+ //------------------------------------------------------------------------------
786
+
787
+ // c_is_partitioned()
788
+ //
789
+ // Container-based version of the <algorithm> `std::is_partitioned()` function
790
+ // to test whether all elements in the container for which `pred` returns `true`
791
+ // precede those for which `pred` is `false`.
792
+ template <typename C, typename Pred>
793
+ bool c_is_partitioned(const C& c, Pred&& pred) {
794
+ return std::is_partitioned(container_algorithm_internal::c_begin(c),
795
+ container_algorithm_internal::c_end(c),
796
+ std::forward<Pred>(pred));
797
+ }
798
+
799
+ // c_partition()
800
+ //
801
+ // Container-based version of the <algorithm> `std::partition()` function
802
+ // to rearrange all elements in a container in such a way that all elements for
803
+ // which `pred` returns `true` precede all those for which it returns `false`,
804
+ // returning an iterator to the first element of the second group.
805
+ template <typename C, typename Pred>
806
+ container_algorithm_internal::ContainerIter<C> c_partition(C& c, Pred&& pred) {
807
+ return std::partition(container_algorithm_internal::c_begin(c),
808
+ container_algorithm_internal::c_end(c),
809
+ std::forward<Pred>(pred));
810
+ }
811
+
812
+ // c_stable_partition()
813
+ //
814
+ // Container-based version of the <algorithm> `std::stable_partition()` function
815
+ // to rearrange all elements in a container in such a way that all elements for
816
+ // which `pred` returns `true` precede all those for which it returns `false`,
817
+ // preserving the relative ordering between the two groups. The function returns
818
+ // an iterator to the first element of the second group.
819
+ template <typename C, typename Pred>
820
+ container_algorithm_internal::ContainerIter<C> c_stable_partition(C& c,
821
+ Pred&& pred) {
822
+ return std::stable_partition(container_algorithm_internal::c_begin(c),
823
+ container_algorithm_internal::c_end(c),
824
+ std::forward<Pred>(pred));
825
+ }
826
+
827
+ // c_partition_copy()
828
+ //
829
+ // Container-based version of the <algorithm> `std::partition_copy()` function
830
+ // to partition a container's elements and return them into two iterators: one
831
+ // for which `pred` returns `true`, and one for which `pred` returns `false.`
832
+
833
+ template <typename C, typename OutputIterator1, typename OutputIterator2,
834
+ typename Pred>
835
+ std::pair<OutputIterator1, OutputIterator2> c_partition_copy(
836
+ const C& c, OutputIterator1 out_true, OutputIterator2 out_false,
837
+ Pred&& pred) {
838
+ return std::partition_copy(container_algorithm_internal::c_begin(c),
839
+ container_algorithm_internal::c_end(c), out_true,
840
+ out_false, std::forward<Pred>(pred));
841
+ }
842
+
843
+ // c_partition_point()
844
+ //
845
+ // Container-based version of the <algorithm> `std::partition_point()` function
846
+ // to return the first element of an already partitioned container for which
847
+ // the given `pred` is not `true`.
848
+ template <typename C, typename Pred>
849
+ container_algorithm_internal::ContainerIter<C> c_partition_point(C& c,
850
+ Pred&& pred) {
851
+ return std::partition_point(container_algorithm_internal::c_begin(c),
852
+ container_algorithm_internal::c_end(c),
853
+ std::forward<Pred>(pred));
854
+ }
855
+
856
+ //------------------------------------------------------------------------------
857
+ // <algorithm> Sorting functions
858
+ //------------------------------------------------------------------------------
859
+
860
+ // c_sort()
861
+ //
862
+ // Container-based version of the <algorithm> `std::sort()` function
863
+ // to sort elements in ascending order of their values.
864
+ template <typename C>
865
+ void c_sort(C& c) {
866
+ std::sort(container_algorithm_internal::c_begin(c),
867
+ container_algorithm_internal::c_end(c));
868
+ }
869
+
870
+ // Overload of c_sort() for performing a `comp` comparison other than the
871
+ // default `operator<`.
872
+ template <typename C, typename Compare>
873
+ void c_sort(C& c, Compare&& comp) {
874
+ std::sort(container_algorithm_internal::c_begin(c),
875
+ container_algorithm_internal::c_end(c),
876
+ std::forward<Compare>(comp));
877
+ }
878
+
879
+ // c_stable_sort()
880
+ //
881
+ // Container-based version of the <algorithm> `std::stable_sort()` function
882
+ // to sort elements in ascending order of their values, preserving the order
883
+ // of equivalents.
884
+ template <typename C>
885
+ void c_stable_sort(C& c) {
886
+ std::stable_sort(container_algorithm_internal::c_begin(c),
887
+ container_algorithm_internal::c_end(c));
888
+ }
889
+
890
+ // Overload of c_stable_sort() for performing a `comp` comparison other than the
891
+ // default `operator<`.
892
+ template <typename C, typename Compare>
893
+ void c_stable_sort(C& c, Compare&& comp) {
894
+ std::stable_sort(container_algorithm_internal::c_begin(c),
895
+ container_algorithm_internal::c_end(c),
896
+ std::forward<Compare>(comp));
897
+ }
898
+
899
+ // c_is_sorted()
900
+ //
901
+ // Container-based version of the <algorithm> `std::is_sorted()` function
902
+ // to evaluate whether the given container is sorted in ascending order.
903
+ template <typename C>
904
+ bool c_is_sorted(const C& c) {
905
+ return std::is_sorted(container_algorithm_internal::c_begin(c),
906
+ container_algorithm_internal::c_end(c));
907
+ }
908
+
909
+ // c_is_sorted() overload for performing a `comp` comparison other than the
910
+ // default `operator<`.
911
+ template <typename C, typename Compare>
912
+ bool c_is_sorted(const C& c, Compare&& comp) {
913
+ return std::is_sorted(container_algorithm_internal::c_begin(c),
914
+ container_algorithm_internal::c_end(c),
915
+ std::forward<Compare>(comp));
916
+ }
917
+
918
+ // c_partial_sort()
919
+ //
920
+ // Container-based version of the <algorithm> `std::partial_sort()` function
921
+ // to rearrange elements within a container such that elements before `middle`
922
+ // are sorted in ascending order.
923
+ template <typename RandomAccessContainer>
924
+ void c_partial_sort(
925
+ RandomAccessContainer& sequence,
926
+ container_algorithm_internal::ContainerIter<RandomAccessContainer> middle) {
927
+ std::partial_sort(container_algorithm_internal::c_begin(sequence), middle,
928
+ container_algorithm_internal::c_end(sequence));
929
+ }
930
+
931
+ // Overload of c_partial_sort() for performing a `comp` comparison other than
932
+ // the default `operator<`.
933
+ template <typename RandomAccessContainer, typename Compare>
934
+ void c_partial_sort(
935
+ RandomAccessContainer& sequence,
936
+ container_algorithm_internal::ContainerIter<RandomAccessContainer> middle,
937
+ Compare&& comp) {
938
+ std::partial_sort(container_algorithm_internal::c_begin(sequence), middle,
939
+ container_algorithm_internal::c_end(sequence),
940
+ std::forward<Compare>(comp));
941
+ }
942
+
943
+ // c_partial_sort_copy()
944
+ //
945
+ // Container-based version of the <algorithm> `std::partial_sort_copy()`
946
+ // function to sort elements within a container such that elements before
947
+ // `middle` are sorted in ascending order, and return the result within an
948
+ // iterator.
949
+ template <typename C, typename RandomAccessContainer>
950
+ container_algorithm_internal::ContainerIter<RandomAccessContainer>
951
+ c_partial_sort_copy(const C& sequence, RandomAccessContainer& result) {
952
+ return std::partial_sort_copy(container_algorithm_internal::c_begin(sequence),
953
+ container_algorithm_internal::c_end(sequence),
954
+ container_algorithm_internal::c_begin(result),
955
+ container_algorithm_internal::c_end(result));
956
+ }
957
+
958
+ // Overload of c_partial_sort_copy() for performing a `comp` comparison other
959
+ // than the default `operator<`.
960
+ template <typename C, typename RandomAccessContainer, typename Compare>
961
+ container_algorithm_internal::ContainerIter<RandomAccessContainer>
962
+ c_partial_sort_copy(const C& sequence, RandomAccessContainer& result,
963
+ Compare&& comp) {
964
+ return std::partial_sort_copy(container_algorithm_internal::c_begin(sequence),
965
+ container_algorithm_internal::c_end(sequence),
966
+ container_algorithm_internal::c_begin(result),
967
+ container_algorithm_internal::c_end(result),
968
+ std::forward<Compare>(comp));
969
+ }
970
+
971
+ // c_is_sorted_until()
972
+ //
973
+ // Container-based version of the <algorithm> `std::is_sorted_until()` function
974
+ // to return the first element within a container that is not sorted in
975
+ // ascending order as an iterator.
976
+ template <typename C>
977
+ container_algorithm_internal::ContainerIter<C> c_is_sorted_until(C& c) {
978
+ return std::is_sorted_until(container_algorithm_internal::c_begin(c),
979
+ container_algorithm_internal::c_end(c));
980
+ }
981
+
982
+ // Overload of c_is_sorted_until() for performing a `comp` comparison other than
983
+ // the default `operator<`.
984
+ template <typename C, typename Compare>
985
+ container_algorithm_internal::ContainerIter<C> c_is_sorted_until(
986
+ C& c, Compare&& comp) {
987
+ return std::is_sorted_until(container_algorithm_internal::c_begin(c),
988
+ container_algorithm_internal::c_end(c),
989
+ std::forward<Compare>(comp));
990
+ }
991
+
992
+ // c_nth_element()
993
+ //
994
+ // Container-based version of the <algorithm> `std::nth_element()` function
995
+ // to rearrange the elements within a container such that the `nth` element
996
+ // would be in that position in an ordered sequence; other elements may be in
997
+ // any order, except that all preceding `nth` will be less than that element,
998
+ // and all following `nth` will be greater than that element.
999
+ template <typename RandomAccessContainer>
1000
+ void c_nth_element(
1001
+ RandomAccessContainer& sequence,
1002
+ container_algorithm_internal::ContainerIter<RandomAccessContainer> nth) {
1003
+ std::nth_element(container_algorithm_internal::c_begin(sequence), nth,
1004
+ container_algorithm_internal::c_end(sequence));
1005
+ }
1006
+
1007
+ // Overload of c_nth_element() for performing a `comp` comparison other than
1008
+ // the default `operator<`.
1009
+ template <typename RandomAccessContainer, typename Compare>
1010
+ void c_nth_element(
1011
+ RandomAccessContainer& sequence,
1012
+ container_algorithm_internal::ContainerIter<RandomAccessContainer> nth,
1013
+ Compare&& comp) {
1014
+ std::nth_element(container_algorithm_internal::c_begin(sequence), nth,
1015
+ container_algorithm_internal::c_end(sequence),
1016
+ std::forward<Compare>(comp));
1017
+ }
1018
+
1019
+ //------------------------------------------------------------------------------
1020
+ // <algorithm> Binary Search
1021
+ //------------------------------------------------------------------------------
1022
+
1023
+ // c_lower_bound()
1024
+ //
1025
+ // Container-based version of the <algorithm> `std::lower_bound()` function
1026
+ // to return an iterator pointing to the first element in a sorted container
1027
+ // which does not compare less than `value`.
1028
+ template <typename Sequence, typename T>
1029
+ container_algorithm_internal::ContainerIter<Sequence> c_lower_bound(
1030
+ Sequence& sequence, T&& value) {
1031
+ return std::lower_bound(container_algorithm_internal::c_begin(sequence),
1032
+ container_algorithm_internal::c_end(sequence),
1033
+ std::forward<T>(value));
1034
+ }
1035
+
1036
+ // Overload of c_lower_bound() for performing a `comp` comparison other than
1037
+ // the default `operator<`.
1038
+ template <typename Sequence, typename T, typename Compare>
1039
+ container_algorithm_internal::ContainerIter<Sequence> c_lower_bound(
1040
+ Sequence& sequence, T&& value, Compare&& comp) {
1041
+ return std::lower_bound(container_algorithm_internal::c_begin(sequence),
1042
+ container_algorithm_internal::c_end(sequence),
1043
+ std::forward<T>(value), std::forward<Compare>(comp));
1044
+ }
1045
+
1046
+ // c_upper_bound()
1047
+ //
1048
+ // Container-based version of the <algorithm> `std::upper_bound()` function
1049
+ // to return an iterator pointing to the first element in a sorted container
1050
+ // which is greater than `value`.
1051
+ template <typename Sequence, typename T>
1052
+ container_algorithm_internal::ContainerIter<Sequence> c_upper_bound(
1053
+ Sequence& sequence, T&& value) {
1054
+ return std::upper_bound(container_algorithm_internal::c_begin(sequence),
1055
+ container_algorithm_internal::c_end(sequence),
1056
+ std::forward<T>(value));
1057
+ }
1058
+
1059
+ // Overload of c_upper_bound() for performing a `comp` comparison other than
1060
+ // the default `operator<`.
1061
+ template <typename Sequence, typename T, typename Compare>
1062
+ container_algorithm_internal::ContainerIter<Sequence> c_upper_bound(
1063
+ Sequence& sequence, T&& value, Compare&& comp) {
1064
+ return std::upper_bound(container_algorithm_internal::c_begin(sequence),
1065
+ container_algorithm_internal::c_end(sequence),
1066
+ std::forward<T>(value), std::forward<Compare>(comp));
1067
+ }
1068
+
1069
+ // c_equal_range()
1070
+ //
1071
+ // Container-based version of the <algorithm> `std::equal_range()` function
1072
+ // to return an iterator pair pointing to the first and last elements in a
1073
+ // sorted container which compare equal to `value`.
1074
+ template <typename Sequence, typename T>
1075
+ container_algorithm_internal::ContainerIterPairType<Sequence, Sequence>
1076
+ c_equal_range(Sequence& sequence, T&& value) {
1077
+ return std::equal_range(container_algorithm_internal::c_begin(sequence),
1078
+ container_algorithm_internal::c_end(sequence),
1079
+ std::forward<T>(value));
1080
+ }
1081
+
1082
+ // Overload of c_equal_range() for performing a `comp` comparison other than
1083
+ // the default `operator<`.
1084
+ template <typename Sequence, typename T, typename Compare>
1085
+ container_algorithm_internal::ContainerIterPairType<Sequence, Sequence>
1086
+ c_equal_range(Sequence& sequence, T&& value, Compare&& comp) {
1087
+ return std::equal_range(container_algorithm_internal::c_begin(sequence),
1088
+ container_algorithm_internal::c_end(sequence),
1089
+ std::forward<T>(value), std::forward<Compare>(comp));
1090
+ }
1091
+
1092
+ // c_binary_search()
1093
+ //
1094
+ // Container-based version of the <algorithm> `std::binary_search()` function
1095
+ // to test if any element in the sorted container contains a value equivalent to
1096
+ // 'value'.
1097
+ template <typename Sequence, typename T>
1098
+ bool c_binary_search(Sequence&& sequence, T&& value) {
1099
+ return std::binary_search(container_algorithm_internal::c_begin(sequence),
1100
+ container_algorithm_internal::c_end(sequence),
1101
+ std::forward<T>(value));
1102
+ }
1103
+
1104
+ // Overload of c_binary_search() for performing a `comp` comparison other than
1105
+ // the default `operator<`.
1106
+ template <typename Sequence, typename T, typename Compare>
1107
+ bool c_binary_search(Sequence&& sequence, T&& value, Compare&& comp) {
1108
+ return std::binary_search(container_algorithm_internal::c_begin(sequence),
1109
+ container_algorithm_internal::c_end(sequence),
1110
+ std::forward<T>(value),
1111
+ std::forward<Compare>(comp));
1112
+ }
1113
+
1114
+ //------------------------------------------------------------------------------
1115
+ // <algorithm> Merge functions
1116
+ //------------------------------------------------------------------------------
1117
+
1118
+ // c_merge()
1119
+ //
1120
+ // Container-based version of the <algorithm> `std::merge()` function
1121
+ // to merge two sorted containers into a single sorted iterator.
1122
+ template <typename C1, typename C2, typename OutputIterator>
1123
+ OutputIterator c_merge(const C1& c1, const C2& c2, OutputIterator result) {
1124
+ return std::merge(container_algorithm_internal::c_begin(c1),
1125
+ container_algorithm_internal::c_end(c1),
1126
+ container_algorithm_internal::c_begin(c2),
1127
+ container_algorithm_internal::c_end(c2), result);
1128
+ }
1129
+
1130
+ // Overload of c_merge() for performing a `comp` comparison other than
1131
+ // the default `operator<`.
1132
+ template <typename C1, typename C2, typename OutputIterator, typename Compare>
1133
+ OutputIterator c_merge(const C1& c1, const C2& c2, OutputIterator result,
1134
+ Compare&& comp) {
1135
+ return std::merge(container_algorithm_internal::c_begin(c1),
1136
+ container_algorithm_internal::c_end(c1),
1137
+ container_algorithm_internal::c_begin(c2),
1138
+ container_algorithm_internal::c_end(c2), result,
1139
+ std::forward<Compare>(comp));
1140
+ }
1141
+
1142
+ // c_inplace_merge()
1143
+ //
1144
+ // Container-based version of the <algorithm> `std::inplace_merge()` function
1145
+ // to merge a supplied iterator `middle` into a container.
1146
+ template <typename C>
1147
+ void c_inplace_merge(C& c,
1148
+ container_algorithm_internal::ContainerIter<C> middle) {
1149
+ std::inplace_merge(container_algorithm_internal::c_begin(c), middle,
1150
+ container_algorithm_internal::c_end(c));
1151
+ }
1152
+
1153
+ // Overload of c_inplace_merge() for performing a merge using a `comp` other
1154
+ // than `operator<`.
1155
+ template <typename C, typename Compare>
1156
+ void c_inplace_merge(C& c,
1157
+ container_algorithm_internal::ContainerIter<C> middle,
1158
+ Compare&& comp) {
1159
+ std::inplace_merge(container_algorithm_internal::c_begin(c), middle,
1160
+ container_algorithm_internal::c_end(c),
1161
+ std::forward<Compare>(comp));
1162
+ }
1163
+
1164
+ // c_includes()
1165
+ //
1166
+ // Container-based version of the <algorithm> `std::includes()` function
1167
+ // to test whether a sorted container `c1` entirely contains another sorted
1168
+ // container `c2`.
1169
+ template <typename C1, typename C2>
1170
+ bool c_includes(const C1& c1, const C2& c2) {
1171
+ return std::includes(container_algorithm_internal::c_begin(c1),
1172
+ container_algorithm_internal::c_end(c1),
1173
+ container_algorithm_internal::c_begin(c2),
1174
+ container_algorithm_internal::c_end(c2));
1175
+ }
1176
+
1177
+ // Overload of c_includes() for performing a merge using a `comp` other than
1178
+ // `operator<`.
1179
+ template <typename C1, typename C2, typename Compare>
1180
+ bool c_includes(const C1& c1, const C2& c2, Compare&& comp) {
1181
+ return std::includes(container_algorithm_internal::c_begin(c1),
1182
+ container_algorithm_internal::c_end(c1),
1183
+ container_algorithm_internal::c_begin(c2),
1184
+ container_algorithm_internal::c_end(c2),
1185
+ std::forward<Compare>(comp));
1186
+ }
1187
+
1188
+ // c_set_union()
1189
+ //
1190
+ // Container-based version of the <algorithm> `std::set_union()` function
1191
+ // to return an iterator containing the union of two containers; duplicate
1192
+ // values are not copied into the output.
1193
+ template <typename C1, typename C2, typename OutputIterator,
1194
+ typename = typename std::enable_if<
1195
+ !container_algorithm_internal::IsUnorderedContainer<C1>::value,
1196
+ void>::type,
1197
+ typename = typename std::enable_if<
1198
+ !container_algorithm_internal::IsUnorderedContainer<C2>::value,
1199
+ void>::type>
1200
+ OutputIterator c_set_union(const C1& c1, const C2& c2, OutputIterator output) {
1201
+ return std::set_union(container_algorithm_internal::c_begin(c1),
1202
+ container_algorithm_internal::c_end(c1),
1203
+ container_algorithm_internal::c_begin(c2),
1204
+ container_algorithm_internal::c_end(c2), output);
1205
+ }
1206
+
1207
+ // Overload of c_set_union() for performing a merge using a `comp` other than
1208
+ // `operator<`.
1209
+ template <typename C1, typename C2, typename OutputIterator, typename Compare,
1210
+ typename = typename std::enable_if<
1211
+ !container_algorithm_internal::IsUnorderedContainer<C1>::value,
1212
+ void>::type,
1213
+ typename = typename std::enable_if<
1214
+ !container_algorithm_internal::IsUnorderedContainer<C2>::value,
1215
+ void>::type>
1216
+ OutputIterator c_set_union(const C1& c1, const C2& c2, OutputIterator output,
1217
+ Compare&& comp) {
1218
+ return std::set_union(container_algorithm_internal::c_begin(c1),
1219
+ container_algorithm_internal::c_end(c1),
1220
+ container_algorithm_internal::c_begin(c2),
1221
+ container_algorithm_internal::c_end(c2), output,
1222
+ std::forward<Compare>(comp));
1223
+ }
1224
+
1225
+ // c_set_intersection()
1226
+ //
1227
+ // Container-based version of the <algorithm> `std::set_intersection()` function
1228
+ // to return an iterator containing the intersection of two containers.
1229
+ template <typename C1, typename C2, typename OutputIterator,
1230
+ typename = typename std::enable_if<
1231
+ !container_algorithm_internal::IsUnorderedContainer<C1>::value,
1232
+ void>::type,
1233
+ typename = typename std::enable_if<
1234
+ !container_algorithm_internal::IsUnorderedContainer<C2>::value,
1235
+ void>::type>
1236
+ OutputIterator c_set_intersection(const C1& c1, const C2& c2,
1237
+ OutputIterator output) {
1238
+ return std::set_intersection(container_algorithm_internal::c_begin(c1),
1239
+ container_algorithm_internal::c_end(c1),
1240
+ container_algorithm_internal::c_begin(c2),
1241
+ container_algorithm_internal::c_end(c2), output);
1242
+ }
1243
+
1244
+ // Overload of c_set_intersection() for performing a merge using a `comp` other
1245
+ // than `operator<`.
1246
+ template <typename C1, typename C2, typename OutputIterator, typename Compare,
1247
+ typename = typename std::enable_if<
1248
+ !container_algorithm_internal::IsUnorderedContainer<C1>::value,
1249
+ void>::type,
1250
+ typename = typename std::enable_if<
1251
+ !container_algorithm_internal::IsUnorderedContainer<C2>::value,
1252
+ void>::type>
1253
+ OutputIterator c_set_intersection(const C1& c1, const C2& c2,
1254
+ OutputIterator output, Compare&& comp) {
1255
+ return std::set_intersection(container_algorithm_internal::c_begin(c1),
1256
+ container_algorithm_internal::c_end(c1),
1257
+ container_algorithm_internal::c_begin(c2),
1258
+ container_algorithm_internal::c_end(c2), output,
1259
+ std::forward<Compare>(comp));
1260
+ }
1261
+
1262
+ // c_set_difference()
1263
+ //
1264
+ // Container-based version of the <algorithm> `std::set_difference()` function
1265
+ // to return an iterator containing elements present in the first container but
1266
+ // not in the second.
1267
+ template <typename C1, typename C2, typename OutputIterator,
1268
+ typename = typename std::enable_if<
1269
+ !container_algorithm_internal::IsUnorderedContainer<C1>::value,
1270
+ void>::type,
1271
+ typename = typename std::enable_if<
1272
+ !container_algorithm_internal::IsUnorderedContainer<C2>::value,
1273
+ void>::type>
1274
+ OutputIterator c_set_difference(const C1& c1, const C2& c2,
1275
+ OutputIterator output) {
1276
+ return std::set_difference(container_algorithm_internal::c_begin(c1),
1277
+ container_algorithm_internal::c_end(c1),
1278
+ container_algorithm_internal::c_begin(c2),
1279
+ container_algorithm_internal::c_end(c2), output);
1280
+ }
1281
+
1282
+ // Overload of c_set_difference() for performing a merge using a `comp` other
1283
+ // than `operator<`.
1284
+ template <typename C1, typename C2, typename OutputIterator, typename Compare,
1285
+ typename = typename std::enable_if<
1286
+ !container_algorithm_internal::IsUnorderedContainer<C1>::value,
1287
+ void>::type,
1288
+ typename = typename std::enable_if<
1289
+ !container_algorithm_internal::IsUnorderedContainer<C2>::value,
1290
+ void>::type>
1291
+ OutputIterator c_set_difference(const C1& c1, const C2& c2,
1292
+ OutputIterator output, Compare&& comp) {
1293
+ return std::set_difference(container_algorithm_internal::c_begin(c1),
1294
+ container_algorithm_internal::c_end(c1),
1295
+ container_algorithm_internal::c_begin(c2),
1296
+ container_algorithm_internal::c_end(c2), output,
1297
+ std::forward<Compare>(comp));
1298
+ }
1299
+
1300
+ // c_set_symmetric_difference()
1301
+ //
1302
+ // Container-based version of the <algorithm> `std::set_symmetric_difference()`
1303
+ // function to return an iterator containing elements present in either one
1304
+ // container or the other, but not both.
1305
+ template <typename C1, typename C2, typename OutputIterator,
1306
+ typename = typename std::enable_if<
1307
+ !container_algorithm_internal::IsUnorderedContainer<C1>::value,
1308
+ void>::type,
1309
+ typename = typename std::enable_if<
1310
+ !container_algorithm_internal::IsUnorderedContainer<C2>::value,
1311
+ void>::type>
1312
+ OutputIterator c_set_symmetric_difference(const C1& c1, const C2& c2,
1313
+ OutputIterator output) {
1314
+ return std::set_symmetric_difference(
1315
+ container_algorithm_internal::c_begin(c1),
1316
+ container_algorithm_internal::c_end(c1),
1317
+ container_algorithm_internal::c_begin(c2),
1318
+ container_algorithm_internal::c_end(c2), output);
1319
+ }
1320
+
1321
+ // Overload of c_set_symmetric_difference() for performing a merge using a
1322
+ // `comp` other than `operator<`.
1323
+ template <typename C1, typename C2, typename OutputIterator, typename Compare,
1324
+ typename = typename std::enable_if<
1325
+ !container_algorithm_internal::IsUnorderedContainer<C1>::value,
1326
+ void>::type,
1327
+ typename = typename std::enable_if<
1328
+ !container_algorithm_internal::IsUnorderedContainer<C2>::value,
1329
+ void>::type>
1330
+ OutputIterator c_set_symmetric_difference(const C1& c1, const C2& c2,
1331
+ OutputIterator output,
1332
+ Compare&& comp) {
1333
+ return std::set_symmetric_difference(
1334
+ container_algorithm_internal::c_begin(c1),
1335
+ container_algorithm_internal::c_end(c1),
1336
+ container_algorithm_internal::c_begin(c2),
1337
+ container_algorithm_internal::c_end(c2), output,
1338
+ std::forward<Compare>(comp));
1339
+ }
1340
+
1341
+ //------------------------------------------------------------------------------
1342
+ // <algorithm> Heap functions
1343
+ //------------------------------------------------------------------------------
1344
+
1345
+ // c_push_heap()
1346
+ //
1347
+ // Container-based version of the <algorithm> `std::push_heap()` function
1348
+ // to push a value onto a container heap.
1349
+ template <typename RandomAccessContainer>
1350
+ void c_push_heap(RandomAccessContainer& sequence) {
1351
+ std::push_heap(container_algorithm_internal::c_begin(sequence),
1352
+ container_algorithm_internal::c_end(sequence));
1353
+ }
1354
+
1355
+ // Overload of c_push_heap() for performing a push operation on a heap using a
1356
+ // `comp` other than `operator<`.
1357
+ template <typename RandomAccessContainer, typename Compare>
1358
+ void c_push_heap(RandomAccessContainer& sequence, Compare&& comp) {
1359
+ std::push_heap(container_algorithm_internal::c_begin(sequence),
1360
+ container_algorithm_internal::c_end(sequence),
1361
+ std::forward<Compare>(comp));
1362
+ }
1363
+
1364
+ // c_pop_heap()
1365
+ //
1366
+ // Container-based version of the <algorithm> `std::pop_heap()` function
1367
+ // to pop a value from a heap container.
1368
+ template <typename RandomAccessContainer>
1369
+ void c_pop_heap(RandomAccessContainer& sequence) {
1370
+ std::pop_heap(container_algorithm_internal::c_begin(sequence),
1371
+ container_algorithm_internal::c_end(sequence));
1372
+ }
1373
+
1374
+ // Overload of c_pop_heap() for performing a pop operation on a heap using a
1375
+ // `comp` other than `operator<`.
1376
+ template <typename RandomAccessContainer, typename Compare>
1377
+ void c_pop_heap(RandomAccessContainer& sequence, Compare&& comp) {
1378
+ std::pop_heap(container_algorithm_internal::c_begin(sequence),
1379
+ container_algorithm_internal::c_end(sequence),
1380
+ std::forward<Compare>(comp));
1381
+ }
1382
+
1383
+ // c_make_heap()
1384
+ //
1385
+ // Container-based version of the <algorithm> `std::make_heap()` function
1386
+ // to make a container a heap.
1387
+ template <typename RandomAccessContainer>
1388
+ void c_make_heap(RandomAccessContainer& sequence) {
1389
+ std::make_heap(container_algorithm_internal::c_begin(sequence),
1390
+ container_algorithm_internal::c_end(sequence));
1391
+ }
1392
+
1393
+ // Overload of c_make_heap() for performing heap comparisons using a
1394
+ // `comp` other than `operator<`
1395
+ template <typename RandomAccessContainer, typename Compare>
1396
+ void c_make_heap(RandomAccessContainer& sequence, Compare&& comp) {
1397
+ std::make_heap(container_algorithm_internal::c_begin(sequence),
1398
+ container_algorithm_internal::c_end(sequence),
1399
+ std::forward<Compare>(comp));
1400
+ }
1401
+
1402
+ // c_sort_heap()
1403
+ //
1404
+ // Container-based version of the <algorithm> `std::sort_heap()` function
1405
+ // to sort a heap into ascending order (after which it is no longer a heap).
1406
+ template <typename RandomAccessContainer>
1407
+ void c_sort_heap(RandomAccessContainer& sequence) {
1408
+ std::sort_heap(container_algorithm_internal::c_begin(sequence),
1409
+ container_algorithm_internal::c_end(sequence));
1410
+ }
1411
+
1412
+ // Overload of c_sort_heap() for performing heap comparisons using a
1413
+ // `comp` other than `operator<`
1414
+ template <typename RandomAccessContainer, typename Compare>
1415
+ void c_sort_heap(RandomAccessContainer& sequence, Compare&& comp) {
1416
+ std::sort_heap(container_algorithm_internal::c_begin(sequence),
1417
+ container_algorithm_internal::c_end(sequence),
1418
+ std::forward<Compare>(comp));
1419
+ }
1420
+
1421
+ // c_is_heap()
1422
+ //
1423
+ // Container-based version of the <algorithm> `std::is_heap()` function
1424
+ // to check whether the given container is a heap.
1425
+ template <typename RandomAccessContainer>
1426
+ bool c_is_heap(const RandomAccessContainer& sequence) {
1427
+ return std::is_heap(container_algorithm_internal::c_begin(sequence),
1428
+ container_algorithm_internal::c_end(sequence));
1429
+ }
1430
+
1431
+ // Overload of c_is_heap() for performing heap comparisons using a
1432
+ // `comp` other than `operator<`
1433
+ template <typename RandomAccessContainer, typename Compare>
1434
+ bool c_is_heap(const RandomAccessContainer& sequence, Compare&& comp) {
1435
+ return std::is_heap(container_algorithm_internal::c_begin(sequence),
1436
+ container_algorithm_internal::c_end(sequence),
1437
+ std::forward<Compare>(comp));
1438
+ }
1439
+
1440
+ // c_is_heap_until()
1441
+ //
1442
+ // Container-based version of the <algorithm> `std::is_heap_until()` function
1443
+ // to find the first element in a given container which is not in heap order.
1444
+ template <typename RandomAccessContainer>
1445
+ container_algorithm_internal::ContainerIter<RandomAccessContainer>
1446
+ c_is_heap_until(RandomAccessContainer& sequence) {
1447
+ return std::is_heap_until(container_algorithm_internal::c_begin(sequence),
1448
+ container_algorithm_internal::c_end(sequence));
1449
+ }
1450
+
1451
+ // Overload of c_is_heap_until() for performing heap comparisons using a
1452
+ // `comp` other than `operator<`
1453
+ template <typename RandomAccessContainer, typename Compare>
1454
+ container_algorithm_internal::ContainerIter<RandomAccessContainer>
1455
+ c_is_heap_until(RandomAccessContainer& sequence, Compare&& comp) {
1456
+ return std::is_heap_until(container_algorithm_internal::c_begin(sequence),
1457
+ container_algorithm_internal::c_end(sequence),
1458
+ std::forward<Compare>(comp));
1459
+ }
1460
+
1461
+ //------------------------------------------------------------------------------
1462
+ // <algorithm> Min/max
1463
+ //------------------------------------------------------------------------------
1464
+
1465
+ // c_min_element()
1466
+ //
1467
+ // Container-based version of the <algorithm> `std::min_element()` function
1468
+ // to return an iterator pointing to the element with the smallest value, using
1469
+ // `operator<` to make the comparisons.
1470
+ template <typename Sequence>
1471
+ container_algorithm_internal::ContainerIter<Sequence> c_min_element(
1472
+ Sequence& sequence) {
1473
+ return std::min_element(container_algorithm_internal::c_begin(sequence),
1474
+ container_algorithm_internal::c_end(sequence));
1475
+ }
1476
+
1477
+ // Overload of c_min_element() for performing a `comp` comparison other than
1478
+ // `operator<`.
1479
+ template <typename Sequence, typename Compare>
1480
+ container_algorithm_internal::ContainerIter<Sequence> c_min_element(
1481
+ Sequence& sequence, Compare&& comp) {
1482
+ return std::min_element(container_algorithm_internal::c_begin(sequence),
1483
+ container_algorithm_internal::c_end(sequence),
1484
+ std::forward<Compare>(comp));
1485
+ }
1486
+
1487
+ // c_max_element()
1488
+ //
1489
+ // Container-based version of the <algorithm> `std::max_element()` function
1490
+ // to return an iterator pointing to the element with the largest value, using
1491
+ // `operator<` to make the comparisons.
1492
+ template <typename Sequence>
1493
+ container_algorithm_internal::ContainerIter<Sequence> c_max_element(
1494
+ Sequence& sequence) {
1495
+ return std::max_element(container_algorithm_internal::c_begin(sequence),
1496
+ container_algorithm_internal::c_end(sequence));
1497
+ }
1498
+
1499
+ // Overload of c_max_element() for performing a `comp` comparison other than
1500
+ // `operator<`.
1501
+ template <typename Sequence, typename Compare>
1502
+ container_algorithm_internal::ContainerIter<Sequence> c_max_element(
1503
+ Sequence& sequence, Compare&& comp) {
1504
+ return std::max_element(container_algorithm_internal::c_begin(sequence),
1505
+ container_algorithm_internal::c_end(sequence),
1506
+ std::forward<Compare>(comp));
1507
+ }
1508
+
1509
+ // c_minmax_element()
1510
+ //
1511
+ // Container-based version of the <algorithm> `std::minmax_element()` function
1512
+ // to return a pair of iterators pointing to the elements containing the
1513
+ // smallest and largest values, respectively, using `operator<` to make the
1514
+ // comparisons.
1515
+ template <typename C>
1516
+ container_algorithm_internal::ContainerIterPairType<C, C>
1517
+ c_minmax_element(C& c) {
1518
+ return std::minmax_element(container_algorithm_internal::c_begin(c),
1519
+ container_algorithm_internal::c_end(c));
1520
+ }
1521
+
1522
+ // Overload of c_minmax_element() for performing `comp` comparisons other than
1523
+ // `operator<`.
1524
+ template <typename C, typename Compare>
1525
+ container_algorithm_internal::ContainerIterPairType<C, C>
1526
+ c_minmax_element(C& c, Compare&& comp) {
1527
+ return std::minmax_element(container_algorithm_internal::c_begin(c),
1528
+ container_algorithm_internal::c_end(c),
1529
+ std::forward<Compare>(comp));
1530
+ }
1531
+
1532
+ //------------------------------------------------------------------------------
1533
+ // <algorithm> Lexicographical Comparisons
1534
+ //------------------------------------------------------------------------------
1535
+
1536
+ // c_lexicographical_compare()
1537
+ //
1538
+ // Container-based version of the <algorithm> `std::lexicographical_compare()`
1539
+ // function to lexicographically compare (e.g. sort words alphabetically) two
1540
+ // container sequences. The comparison is performed using `operator<`. Note
1541
+ // that capital letters ("A-Z") have ASCII values less than lowercase letters
1542
+ // ("a-z").
1543
+ template <typename Sequence1, typename Sequence2>
1544
+ bool c_lexicographical_compare(Sequence1&& sequence1, Sequence2&& sequence2) {
1545
+ return std::lexicographical_compare(
1546
+ container_algorithm_internal::c_begin(sequence1),
1547
+ container_algorithm_internal::c_end(sequence1),
1548
+ container_algorithm_internal::c_begin(sequence2),
1549
+ container_algorithm_internal::c_end(sequence2));
1550
+ }
1551
+
1552
+ // Overload of c_lexicographical_compare() for performing a lexicographical
1553
+ // comparison using a `comp` operator instead of `operator<`.
1554
+ template <typename Sequence1, typename Sequence2, typename Compare>
1555
+ bool c_lexicographical_compare(Sequence1&& sequence1, Sequence2&& sequence2,
1556
+ Compare&& comp) {
1557
+ return std::lexicographical_compare(
1558
+ container_algorithm_internal::c_begin(sequence1),
1559
+ container_algorithm_internal::c_end(sequence1),
1560
+ container_algorithm_internal::c_begin(sequence2),
1561
+ container_algorithm_internal::c_end(sequence2),
1562
+ std::forward<Compare>(comp));
1563
+ }
1564
+
1565
+ // c_next_permutation()
1566
+ //
1567
+ // Container-based version of the <algorithm> `std::next_permutation()` function
1568
+ // to rearrange a container's elements into the next lexicographically greater
1569
+ // permutation.
1570
+ template <typename C>
1571
+ bool c_next_permutation(C& c) {
1572
+ return std::next_permutation(container_algorithm_internal::c_begin(c),
1573
+ container_algorithm_internal::c_end(c));
1574
+ }
1575
+
1576
+ // Overload of c_next_permutation() for performing a lexicographical
1577
+ // comparison using a `comp` operator instead of `operator<`.
1578
+ template <typename C, typename Compare>
1579
+ bool c_next_permutation(C& c, Compare&& comp) {
1580
+ return std::next_permutation(container_algorithm_internal::c_begin(c),
1581
+ container_algorithm_internal::c_end(c),
1582
+ std::forward<Compare>(comp));
1583
+ }
1584
+
1585
+ // c_prev_permutation()
1586
+ //
1587
+ // Container-based version of the <algorithm> `std::prev_permutation()` function
1588
+ // to rearrange a container's elements into the next lexicographically lesser
1589
+ // permutation.
1590
+ template <typename C>
1591
+ bool c_prev_permutation(C& c) {
1592
+ return std::prev_permutation(container_algorithm_internal::c_begin(c),
1593
+ container_algorithm_internal::c_end(c));
1594
+ }
1595
+
1596
+ // Overload of c_prev_permutation() for performing a lexicographical
1597
+ // comparison using a `comp` operator instead of `operator<`.
1598
+ template <typename C, typename Compare>
1599
+ bool c_prev_permutation(C& c, Compare&& comp) {
1600
+ return std::prev_permutation(container_algorithm_internal::c_begin(c),
1601
+ container_algorithm_internal::c_end(c),
1602
+ std::forward<Compare>(comp));
1603
+ }
1604
+
1605
+ //------------------------------------------------------------------------------
1606
+ // <numeric> algorithms
1607
+ //------------------------------------------------------------------------------
1608
+
1609
+ // c_iota()
1610
+ //
1611
+ // Container-based version of the <algorithm> `std::iota()` function
1612
+ // to compute successive values of `value`, as if incremented with `++value`
1613
+ // after each element is written. and write them to the container.
1614
+ template <typename Sequence, typename T>
1615
+ void c_iota(Sequence& sequence, T&& value) {
1616
+ std::iota(container_algorithm_internal::c_begin(sequence),
1617
+ container_algorithm_internal::c_end(sequence),
1618
+ std::forward<T>(value));
1619
+ }
1620
+ // c_accumulate()
1621
+ //
1622
+ // Container-based version of the <algorithm> `std::accumulate()` function
1623
+ // to accumulate the element values of a container to `init` and return that
1624
+ // accumulation by value.
1625
+ //
1626
+ // Note: Due to a language technicality this function has return type
1627
+ // absl::decay_t<T>. As a user of this function you can casually read
1628
+ // this as "returns T by value" and assume it does the right thing.
1629
+ template <typename Sequence, typename T>
1630
+ decay_t<T> c_accumulate(const Sequence& sequence, T&& init) {
1631
+ return std::accumulate(container_algorithm_internal::c_begin(sequence),
1632
+ container_algorithm_internal::c_end(sequence),
1633
+ std::forward<T>(init));
1634
+ }
1635
+
1636
+ // Overload of c_accumulate() for using a binary operations other than
1637
+ // addition for computing the accumulation.
1638
+ template <typename Sequence, typename T, typename BinaryOp>
1639
+ decay_t<T> c_accumulate(const Sequence& sequence, T&& init,
1640
+ BinaryOp&& binary_op) {
1641
+ return std::accumulate(container_algorithm_internal::c_begin(sequence),
1642
+ container_algorithm_internal::c_end(sequence),
1643
+ std::forward<T>(init),
1644
+ std::forward<BinaryOp>(binary_op));
1645
+ }
1646
+
1647
+ // c_inner_product()
1648
+ //
1649
+ // Container-based version of the <algorithm> `std::inner_product()` function
1650
+ // to compute the cumulative inner product of container element pairs.
1651
+ //
1652
+ // Note: Due to a language technicality this function has return type
1653
+ // absl::decay_t<T>. As a user of this function you can casually read
1654
+ // this as "returns T by value" and assume it does the right thing.
1655
+ template <typename Sequence1, typename Sequence2, typename T>
1656
+ decay_t<T> c_inner_product(const Sequence1& factors1, const Sequence2& factors2,
1657
+ T&& sum) {
1658
+ return std::inner_product(container_algorithm_internal::c_begin(factors1),
1659
+ container_algorithm_internal::c_end(factors1),
1660
+ container_algorithm_internal::c_begin(factors2),
1661
+ std::forward<T>(sum));
1662
+ }
1663
+
1664
+ // Overload of c_inner_product() for using binary operations other than
1665
+ // `operator+` (for computing the accumulation) and `operator*` (for computing
1666
+ // the product between the two container's element pair).
1667
+ template <typename Sequence1, typename Sequence2, typename T,
1668
+ typename BinaryOp1, typename BinaryOp2>
1669
+ decay_t<T> c_inner_product(const Sequence1& factors1, const Sequence2& factors2,
1670
+ T&& sum, BinaryOp1&& op1, BinaryOp2&& op2) {
1671
+ return std::inner_product(container_algorithm_internal::c_begin(factors1),
1672
+ container_algorithm_internal::c_end(factors1),
1673
+ container_algorithm_internal::c_begin(factors2),
1674
+ std::forward<T>(sum), std::forward<BinaryOp1>(op1),
1675
+ std::forward<BinaryOp2>(op2));
1676
+ }
1677
+
1678
+ // c_adjacent_difference()
1679
+ //
1680
+ // Container-based version of the <algorithm> `std::adjacent_difference()`
1681
+ // function to compute the difference between each element and the one preceding
1682
+ // it and write it to an iterator.
1683
+ template <typename InputSequence, typename OutputIt>
1684
+ OutputIt c_adjacent_difference(const InputSequence& input,
1685
+ OutputIt output_first) {
1686
+ return std::adjacent_difference(container_algorithm_internal::c_begin(input),
1687
+ container_algorithm_internal::c_end(input),
1688
+ output_first);
1689
+ }
1690
+
1691
+ // Overload of c_adjacent_difference() for using a binary operation other than
1692
+ // subtraction to compute the adjacent difference.
1693
+ template <typename InputSequence, typename OutputIt, typename BinaryOp>
1694
+ OutputIt c_adjacent_difference(const InputSequence& input,
1695
+ OutputIt output_first, BinaryOp&& op) {
1696
+ return std::adjacent_difference(container_algorithm_internal::c_begin(input),
1697
+ container_algorithm_internal::c_end(input),
1698
+ output_first, std::forward<BinaryOp>(op));
1699
+ }
1700
+
1701
+ // c_partial_sum()
1702
+ //
1703
+ // Container-based version of the <algorithm> `std::partial_sum()` function
1704
+ // to compute the partial sum of the elements in a sequence and write them
1705
+ // to an iterator. The partial sum is the sum of all element values so far in
1706
+ // the sequence.
1707
+ template <typename InputSequence, typename OutputIt>
1708
+ OutputIt c_partial_sum(const InputSequence& input, OutputIt output_first) {
1709
+ return std::partial_sum(container_algorithm_internal::c_begin(input),
1710
+ container_algorithm_internal::c_end(input),
1711
+ output_first);
1712
+ }
1713
+
1714
+ // Overload of c_partial_sum() for using a binary operation other than addition
1715
+ // to compute the "partial sum".
1716
+ template <typename InputSequence, typename OutputIt, typename BinaryOp>
1717
+ OutputIt c_partial_sum(const InputSequence& input, OutputIt output_first,
1718
+ BinaryOp&& op) {
1719
+ return std::partial_sum(container_algorithm_internal::c_begin(input),
1720
+ container_algorithm_internal::c_end(input),
1721
+ output_first, std::forward<BinaryOp>(op));
1722
+ }
1723
+
1724
+ ABSL_NAMESPACE_END
1725
+ } // namespace absl
1726
+
1727
+ #endif // ABSL_ALGORITHM_CONTAINER_H_