grpc 1.31.1 → 1.32.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 (431) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +595 -15723
  3. data/include/grpc/grpc_security.h +31 -14
  4. data/include/grpc/impl/codegen/README.md +22 -0
  5. data/include/grpc/impl/codegen/port_platform.h +6 -1
  6. data/src/core/ext/filters/client_channel/backup_poller.cc +3 -2
  7. data/src/core/ext/filters/client_channel/client_channel.cc +64 -20
  8. data/src/core/ext/filters/client_channel/client_channel.h +1 -1
  9. data/src/core/ext/filters/client_channel/client_channel_channelz.h +0 -3
  10. data/src/core/ext/filters/client_channel/health/health_check_client.cc +6 -1
  11. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +2 -3
  12. data/src/core/ext/filters/client_channel/lb_policy.h +2 -0
  13. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +6 -4
  14. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +20 -13
  15. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +0 -13
  16. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +0 -3
  17. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -37
  18. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +19 -13
  19. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +29 -10
  20. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +5 -4
  21. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +20 -9
  22. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +18 -12
  23. data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +22 -14
  24. data/src/core/ext/filters/client_channel/lb_policy/xds/lrs.cc +18 -9
  25. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +54 -56
  26. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +3 -3
  27. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +1 -1
  28. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
  29. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +1 -1
  30. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -1
  31. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +363 -14
  32. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +0 -1
  33. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +5 -4
  34. data/src/core/ext/filters/client_channel/server_address.cc +40 -7
  35. data/src/core/ext/filters/client_channel/server_address.h +42 -4
  36. data/src/core/ext/filters/client_channel/subchannel.cc +64 -23
  37. data/src/core/ext/filters/client_channel/subchannel.h +16 -4
  38. data/src/core/ext/filters/max_age/max_age_filter.cc +2 -1
  39. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +87 -31
  40. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +18 -1
  41. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +10 -35
  42. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +19 -25
  43. data/src/core/ext/transport/chttp2/server/chttp2_server.h +2 -1
  44. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +2 -2
  45. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +6 -6
  46. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +3 -2
  47. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +239 -277
  48. data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -1
  49. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +2 -2
  50. data/src/core/ext/transport/chttp2/transport/internal.h +5 -1
  51. data/src/core/ext/transport/chttp2/transport/parsing.cc +1 -28
  52. data/src/core/ext/transport/chttp2/transport/writing.cc +6 -5
  53. data/src/core/ext/transport/inproc/inproc_transport.cc +12 -12
  54. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +224 -0
  55. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +700 -0
  56. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +74 -0
  57. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +226 -0
  58. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +380 -0
  59. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +1378 -0
  60. data/src/core/ext/upb-generated/envoy/{api/v2/cluster → config/cluster/v3}/filter.upb.c +8 -8
  61. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +69 -0
  62. data/src/core/ext/upb-generated/envoy/{api/v2/cluster → config/cluster/v3}/outlier_detection.upb.c +8 -8
  63. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +323 -0
  64. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +112 -0
  65. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +334 -0
  66. data/src/core/ext/upb-generated/envoy/{api/v2/core → config/core/v3}/backoff.upb.c +8 -8
  67. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +79 -0
  68. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +309 -0
  69. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +869 -0
  70. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +96 -0
  71. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +328 -0
  72. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +34 -0
  73. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +71 -0
  74. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +195 -0
  75. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +634 -0
  76. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +170 -0
  77. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +684 -0
  78. data/src/core/ext/upb-generated/envoy/{api/v2/core → config/core/v3}/http_uri.upb.c +8 -8
  79. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +80 -0
  80. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +152 -0
  81. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +536 -0
  82. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +28 -0
  83. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +58 -0
  84. data/src/core/ext/upb-generated/envoy/{api/v2/core → config/core/v3}/socket_option.upb.c +6 -6
  85. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +88 -0
  86. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +91 -0
  87. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +220 -0
  88. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +91 -0
  89. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +273 -0
  90. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +112 -0
  91. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +332 -0
  92. data/src/core/ext/upb-generated/envoy/config/listener/{v2 → v3}/api_listener.upb.c +8 -8
  93. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +65 -0
  94. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +108 -0
  95. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +401 -0
  96. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +138 -0
  97. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +490 -0
  98. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +41 -0
  99. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +94 -0
  100. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +174 -0
  101. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +599 -0
  102. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +63 -0
  103. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +204 -0
  104. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +773 -0
  105. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +2855 -0
  106. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +59 -0
  107. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +135 -0
  108. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +50 -0
  109. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +108 -0
  110. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +312 -0
  111. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +1125 -0
  112. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.c +20 -0
  113. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.h +34 -0
  114. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +111 -0
  115. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +401 -0
  116. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +72 -0
  117. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +198 -0
  118. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +105 -0
  119. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +388 -0
  120. data/src/core/ext/upb-generated/envoy/{api/v2 → service/cluster/v3}/cds.upb.c +5 -6
  121. data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.h +49 -0
  122. data/src/core/ext/upb-generated/envoy/service/discovery/{v2 → v3}/ads.upb.c +5 -4
  123. data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.h +49 -0
  124. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +129 -0
  125. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +386 -0
  126. data/src/core/ext/upb-generated/envoy/{api/v2 → service/endpoint/v3}/eds.upb.c +5 -6
  127. data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.h +49 -0
  128. data/src/core/ext/upb-generated/envoy/{api/v2 → service/listener/v3}/lds.upb.c +5 -6
  129. data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.h +49 -0
  130. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +55 -0
  131. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +136 -0
  132. data/src/core/ext/upb-generated/envoy/{api/v2 → service/route/v3}/rds.upb.c +5 -6
  133. data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.h +49 -0
  134. data/src/core/ext/upb-generated/envoy/{api/v2 → service/route/v3}/srds.upb.c +5 -6
  135. data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.h +49 -0
  136. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +47 -0
  137. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +114 -0
  138. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +35 -0
  139. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +77 -0
  140. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +34 -0
  141. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +71 -0
  142. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +64 -0
  143. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +145 -0
  144. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +53 -0
  145. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +127 -0
  146. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +63 -0
  147. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +188 -0
  148. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +88 -0
  149. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +258 -0
  150. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +90 -0
  151. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +250 -0
  152. data/src/core/ext/upb-generated/envoy/type/{http.upb.c → v3/http.upb.c} +2 -2
  153. data/src/core/ext/upb-generated/envoy/type/{http.upb.h → v3/http.upb.h} +8 -8
  154. data/src/core/ext/upb-generated/envoy/type/{percent.upb.c → v3/percent.upb.c} +9 -8
  155. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +86 -0
  156. data/src/core/ext/upb-generated/envoy/type/{range.upb.c → v3/range.upb.c} +12 -11
  157. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +111 -0
  158. data/src/core/ext/upb-generated/envoy/type/{semantic_version.upb.c → v3/semantic_version.upb.c} +6 -5
  159. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +61 -0
  160. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +234 -0
  161. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +759 -0
  162. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +36 -36
  163. data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +1 -1
  164. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +27 -0
  165. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +53 -0
  166. data/src/core/ext/upb-generated/validate/validate.upb.c +11 -11
  167. data/src/core/ext/upb-generated/validate/validate.upb.h +1 -1
  168. data/src/core/ext/{filters/client_channel/xds → xds}/xds_api.cc +1045 -767
  169. data/src/core/ext/{filters/client_channel/xds → xds}/xds_api.h +114 -99
  170. data/src/core/ext/{filters/client_channel/xds → xds}/xds_bootstrap.cc +44 -2
  171. data/src/core/ext/{filters/client_channel/xds → xds}/xds_bootstrap.h +8 -3
  172. data/src/core/ext/{filters/client_channel/xds → xds}/xds_channel.h +4 -4
  173. data/src/core/ext/{filters/client_channel/xds → xds}/xds_channel_args.h +3 -3
  174. data/src/core/ext/{filters/client_channel/xds → xds}/xds_channel_secure.cc +2 -5
  175. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client.cc +85 -417
  176. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client.h +12 -45
  177. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client_stats.cc +2 -2
  178. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client_stats.h +3 -3
  179. data/src/core/lib/channel/channelz.cc +14 -15
  180. data/src/core/lib/channel/channelz.h +1 -1
  181. data/src/core/lib/channel/channelz_registry.cc +3 -1
  182. data/src/core/lib/gpr/sync_posix.cc +2 -8
  183. data/src/core/lib/iomgr/endpoint.cc +5 -1
  184. data/src/core/lib/iomgr/endpoint.h +7 -3
  185. data/src/core/lib/iomgr/endpoint_cfstream.cc +32 -11
  186. data/src/core/lib/iomgr/ev_posix.cc +0 -2
  187. data/src/core/lib/iomgr/iomgr.cc +0 -10
  188. data/src/core/lib/iomgr/iomgr.h +0 -10
  189. data/src/core/{ext/filters/client_channel → lib/iomgr}/parse_address.cc +1 -1
  190. data/src/core/{ext/filters/client_channel → lib/iomgr}/parse_address.h +3 -3
  191. data/src/core/lib/iomgr/sockaddr_utils.cc +2 -1
  192. data/src/core/lib/iomgr/sockaddr_utils.h +2 -1
  193. data/src/core/lib/iomgr/tcp_custom.cc +32 -16
  194. data/src/core/lib/iomgr/tcp_posix.cc +31 -13
  195. data/src/core/lib/iomgr/tcp_windows.cc +26 -10
  196. data/src/core/lib/security/authorization/authorization_engine.cc +177 -0
  197. data/src/core/lib/security/authorization/authorization_engine.h +84 -0
  198. data/src/core/lib/security/authorization/evaluate_args.cc +153 -0
  199. data/src/core/lib/security/authorization/evaluate_args.h +59 -0
  200. data/src/core/lib/security/authorization/mock_cel/activation.h +57 -0
  201. data/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +42 -0
  202. data/src/core/lib/security/authorization/mock_cel/cel_expression.h +68 -0
  203. data/src/core/lib/security/authorization/mock_cel/cel_value.h +93 -0
  204. data/src/core/lib/security/authorization/mock_cel/evaluator_core.h +67 -0
  205. data/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +56 -0
  206. data/src/core/lib/security/authorization/mock_cel/statusor.h +50 -0
  207. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +56 -38
  208. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +1 -2
  209. data/src/core/lib/security/transport/secure_endpoint.cc +7 -1
  210. data/src/core/lib/surface/call.cc +12 -12
  211. data/src/core/lib/surface/call.h +2 -1
  212. data/src/core/lib/surface/channel.cc +28 -20
  213. data/src/core/lib/surface/channel.h +12 -2
  214. data/src/core/lib/surface/completion_queue.cc +10 -272
  215. data/src/core/lib/surface/completion_queue.h +0 -8
  216. data/src/core/lib/surface/init.cc +1 -3
  217. data/src/core/lib/surface/server.cc +1066 -1244
  218. data/src/core/lib/surface/server.h +363 -87
  219. data/src/core/lib/surface/version.cc +2 -2
  220. data/src/core/lib/transport/authority_override.cc +38 -0
  221. data/src/core/lib/transport/authority_override.h +32 -0
  222. data/src/core/lib/transport/connectivity_state.cc +18 -13
  223. data/src/core/lib/transport/connectivity_state.h +18 -6
  224. data/src/core/lib/transport/error_utils.cc +13 -0
  225. data/src/core/lib/transport/error_utils.h +6 -0
  226. data/src/core/lib/transport/static_metadata.cc +295 -276
  227. data/src/core/lib/transport/static_metadata.h +80 -73
  228. data/src/core/lib/transport/transport.h +7 -0
  229. data/src/core/lib/uri/uri_parser.cc +23 -21
  230. data/src/core/lib/uri/uri_parser.h +3 -1
  231. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +22 -0
  232. data/src/core/tsi/ssl_transport_security.cc +3 -9
  233. data/src/ruby/ext/grpc/rb_channel_credentials.c +9 -0
  234. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -2
  235. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -4
  236. data/src/ruby/lib/grpc/version.rb +1 -1
  237. data/src/ruby/spec/channel_credentials_spec.rb +10 -0
  238. data/src/ruby/spec/generic/active_call_spec.rb +19 -8
  239. data/third_party/abseil-cpp/absl/algorithm/container.h +1727 -0
  240. data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +161 -0
  241. data/third_party/abseil-cpp/absl/base/internal/exponential_biased.cc +93 -0
  242. data/third_party/abseil-cpp/absl/base/internal/exponential_biased.h +130 -0
  243. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +620 -0
  244. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +126 -0
  245. data/third_party/abseil-cpp/absl/container/fixed_array.h +515 -0
  246. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +503 -0
  247. data/third_party/abseil-cpp/absl/container/internal/common.h +202 -0
  248. data/third_party/abseil-cpp/absl/container/internal/container_memory.h +440 -0
  249. data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +146 -0
  250. data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +191 -0
  251. data/third_party/abseil-cpp/absl/container/internal/hashtable_debug_hooks.h +85 -0
  252. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +269 -0
  253. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +297 -0
  254. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc +30 -0
  255. data/third_party/abseil-cpp/absl/container/internal/have_sse.h +49 -0
  256. data/third_party/abseil-cpp/absl/container/internal/layout.h +741 -0
  257. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +48 -0
  258. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +1882 -0
  259. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc +138 -0
  260. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.h +32 -0
  261. data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +1895 -0
  262. data/third_party/abseil-cpp/absl/debugging/internal/demangle.h +71 -0
  263. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc +382 -0
  264. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +134 -0
  265. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +192 -0
  266. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc +125 -0
  267. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +70 -0
  268. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +99 -0
  269. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +248 -0
  270. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_unimplemented-inl.inc +24 -0
  271. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +85 -0
  272. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +346 -0
  273. data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +128 -0
  274. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +194 -0
  275. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.h +158 -0
  276. data/third_party/abseil-cpp/absl/debugging/stacktrace.cc +140 -0
  277. data/third_party/abseil-cpp/absl/debugging/stacktrace.h +231 -0
  278. data/third_party/abseil-cpp/absl/debugging/symbolize.cc +25 -0
  279. data/third_party/abseil-cpp/absl/debugging/symbolize.h +99 -0
  280. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +1480 -0
  281. data/third_party/abseil-cpp/absl/debugging/symbolize_unimplemented.inc +40 -0
  282. data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +81 -0
  283. data/third_party/abseil-cpp/absl/functional/function_ref.h +139 -0
  284. data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +106 -0
  285. data/third_party/abseil-cpp/absl/hash/hash.h +324 -0
  286. data/third_party/abseil-cpp/absl/hash/internal/city.cc +346 -0
  287. data/third_party/abseil-cpp/absl/hash/internal/city.h +96 -0
  288. data/third_party/abseil-cpp/absl/hash/internal/hash.cc +55 -0
  289. data/third_party/abseil-cpp/absl/hash/internal/hash.h +988 -0
  290. data/third_party/abseil-cpp/absl/status/status.cc +447 -0
  291. data/third_party/abseil-cpp/absl/status/status.h +428 -0
  292. data/third_party/abseil-cpp/absl/status/status_payload_printer.cc +43 -0
  293. data/third_party/abseil-cpp/absl/status/status_payload_printer.h +51 -0
  294. data/third_party/abseil-cpp/absl/strings/cord.cc +2019 -0
  295. data/third_party/abseil-cpp/absl/strings/cord.h +1121 -0
  296. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +151 -0
  297. data/third_party/abseil-cpp/absl/synchronization/barrier.cc +52 -0
  298. data/third_party/abseil-cpp/absl/synchronization/barrier.h +79 -0
  299. data/third_party/abseil-cpp/absl/synchronization/blocking_counter.cc +57 -0
  300. data/third_party/abseil-cpp/absl/synchronization/blocking_counter.h +99 -0
  301. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +140 -0
  302. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.h +60 -0
  303. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +697 -0
  304. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.h +141 -0
  305. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +155 -0
  306. data/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +261 -0
  307. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +106 -0
  308. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +115 -0
  309. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +484 -0
  310. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +159 -0
  311. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +2728 -0
  312. data/third_party/abseil-cpp/absl/synchronization/mutex.h +1056 -0
  313. data/third_party/abseil-cpp/absl/synchronization/notification.cc +78 -0
  314. data/third_party/abseil-cpp/absl/synchronization/notification.h +123 -0
  315. data/third_party/abseil-cpp/absl/types/bad_variant_access.cc +64 -0
  316. data/third_party/abseil-cpp/absl/types/bad_variant_access.h +82 -0
  317. data/third_party/abseil-cpp/absl/types/internal/variant.h +1646 -0
  318. data/third_party/abseil-cpp/absl/types/variant.h +861 -0
  319. data/third_party/boringssl-with-bazel/err_data.c +263 -257
  320. data/third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.c +16 -0
  321. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +456 -0
  322. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +192 -0
  323. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +20 -0
  324. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +52 -0
  325. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +1 -1
  326. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +39 -7
  327. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +2 -3
  328. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +11 -0
  329. data/third_party/boringssl-with-bazel/src/ssl/internal.h +4 -0
  330. data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +3 -6
  331. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +10 -0
  332. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +34 -9
  333. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +5 -0
  334. data/third_party/boringssl-with-bazel/src/ssl/tls_record.cc +5 -3
  335. data/third_party/upb/upb/decode.c +64 -15
  336. data/third_party/upb/upb/encode.c +2 -2
  337. data/third_party/upb/upb/msg.h +2 -2
  338. data/third_party/upb/upb/port_def.inc +1 -1
  339. data/third_party/upb/upb/table.c +0 -11
  340. data/third_party/upb/upb/table.int.h +0 -9
  341. data/third_party/upb/upb/upb.c +16 -14
  342. data/third_party/upb/upb/upb.h +26 -0
  343. data/third_party/upb/upb/upb.hpp +2 -0
  344. metadata +257 -155
  345. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +0 -21
  346. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +0 -34
  347. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.c +0 -114
  348. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.h +0 -429
  349. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.c +0 -72
  350. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.h +0 -198
  351. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.c +0 -105
  352. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.h +0 -388
  353. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +0 -52
  354. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.c +0 -403
  355. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.h +0 -1453
  356. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +0 -74
  357. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h +0 -226
  358. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h +0 -69
  359. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +0 -323
  360. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +0 -112
  361. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h +0 -334
  362. data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.h +0 -79
  363. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +0 -313
  364. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +0 -891
  365. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +0 -96
  366. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +0 -328
  367. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.c +0 -34
  368. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.h +0 -71
  369. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +0 -197
  370. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h +0 -649
  371. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +0 -172
  372. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +0 -693
  373. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h +0 -80
  374. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +0 -152
  375. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +0 -536
  376. data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.h +0 -88
  377. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +0 -129
  378. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h +0 -386
  379. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +0 -52
  380. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.c +0 -92
  381. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.h +0 -224
  382. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +0 -18
  383. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h +0 -32
  384. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.c +0 -91
  385. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.h +0 -273
  386. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +0 -112
  387. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h +0 -332
  388. data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.h +0 -52
  389. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.c +0 -109
  390. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.h +0 -415
  391. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.c +0 -18
  392. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.h +0 -32
  393. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.c +0 -145
  394. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.h +0 -538
  395. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.c +0 -43
  396. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.h +0 -111
  397. data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.h +0 -52
  398. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.c +0 -63
  399. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.h +0 -204
  400. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.c +0 -18
  401. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.h +0 -32
  402. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.c +0 -815
  403. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.h +0 -2984
  404. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.c +0 -59
  405. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.h +0 -135
  406. data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.h +0 -52
  407. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.c +0 -228
  408. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.h +0 -732
  409. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.c +0 -316
  410. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.h +0 -1167
  411. data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.h +0 -65
  412. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.c +0 -51
  413. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.h +0 -125
  414. data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h +0 -49
  415. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c +0 -54
  416. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h +0 -136
  417. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.c +0 -63
  418. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.h +0 -145
  419. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.c +0 -53
  420. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.h +0 -133
  421. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.c +0 -88
  422. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.h +0 -258
  423. data/src/core/ext/upb-generated/envoy/type/percent.upb.h +0 -86
  424. data/src/core/ext/upb-generated/envoy/type/range.upb.h +0 -111
  425. data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.h +0 -61
  426. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.c +0 -89
  427. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.h +0 -250
  428. data/src/core/lib/security/transport/target_authority_table.cc +0 -75
  429. data/src/core/lib/security/transport/target_authority_table.h +0 -40
  430. data/src/core/lib/slice/slice_hash_table.h +0 -199
  431. data/src/core/lib/slice/slice_weak_hash_table.h +0 -102
@@ -165,6 +165,15 @@ static VALUE grpc_rb_channel_credentials_init(int argc, VALUE* argv,
165
165
  if (pem_private_key == Qnil && pem_cert_chain == Qnil) {
166
166
  creds = grpc_ssl_credentials_create(pem_root_certs_cstr, NULL, NULL, NULL);
167
167
  } else {
168
+ if (pem_private_key == Qnil) {
169
+ rb_raise(
170
+ rb_eRuntimeError,
171
+ "could not create a credentials because pem_private_key is NULL");
172
+ }
173
+ if (pem_cert_chain == Qnil) {
174
+ rb_raise(rb_eRuntimeError,
175
+ "could not create a credentials because pem_cert_chain is NULL");
176
+ }
168
177
  key_cert_pair.private_key = RSTRING_PTR(pem_private_key);
169
178
  key_cert_pair.cert_chain = RSTRING_PTR(pem_cert_chain);
170
179
  creds = grpc_ssl_credentials_create(pem_root_certs_cstr, &key_cert_pair,
@@ -120,12 +120,12 @@ grpc_auth_context_set_peer_identity_property_name_type grpc_auth_context_set_pee
120
120
  grpc_ssl_session_cache_create_lru_type grpc_ssl_session_cache_create_lru_import;
121
121
  grpc_ssl_session_cache_destroy_type grpc_ssl_session_cache_destroy_import;
122
122
  grpc_ssl_session_cache_create_channel_arg_type grpc_ssl_session_cache_create_channel_arg_import;
123
+ grpc_call_credentials_release_type grpc_call_credentials_release_import;
123
124
  grpc_channel_credentials_release_type grpc_channel_credentials_release_import;
124
125
  grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import;
125
126
  grpc_set_ssl_roots_override_callback_type grpc_set_ssl_roots_override_callback_import;
126
127
  grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import;
127
128
  grpc_ssl_credentials_create_ex_type grpc_ssl_credentials_create_ex_import;
128
- grpc_call_credentials_release_type grpc_call_credentials_release_import;
129
129
  grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import;
130
130
  grpc_composite_call_credentials_create_type grpc_composite_call_credentials_create_import;
131
131
  grpc_google_compute_engine_credentials_create_type grpc_google_compute_engine_credentials_create_import;
@@ -394,12 +394,12 @@ void grpc_rb_load_imports(HMODULE library) {
394
394
  grpc_ssl_session_cache_create_lru_import = (grpc_ssl_session_cache_create_lru_type) GetProcAddress(library, "grpc_ssl_session_cache_create_lru");
395
395
  grpc_ssl_session_cache_destroy_import = (grpc_ssl_session_cache_destroy_type) GetProcAddress(library, "grpc_ssl_session_cache_destroy");
396
396
  grpc_ssl_session_cache_create_channel_arg_import = (grpc_ssl_session_cache_create_channel_arg_type) GetProcAddress(library, "grpc_ssl_session_cache_create_channel_arg");
397
+ grpc_call_credentials_release_import = (grpc_call_credentials_release_type) GetProcAddress(library, "grpc_call_credentials_release");
397
398
  grpc_channel_credentials_release_import = (grpc_channel_credentials_release_type) GetProcAddress(library, "grpc_channel_credentials_release");
398
399
  grpc_google_default_credentials_create_import = (grpc_google_default_credentials_create_type) GetProcAddress(library, "grpc_google_default_credentials_create");
399
400
  grpc_set_ssl_roots_override_callback_import = (grpc_set_ssl_roots_override_callback_type) GetProcAddress(library, "grpc_set_ssl_roots_override_callback");
400
401
  grpc_ssl_credentials_create_import = (grpc_ssl_credentials_create_type) GetProcAddress(library, "grpc_ssl_credentials_create");
401
402
  grpc_ssl_credentials_create_ex_import = (grpc_ssl_credentials_create_ex_type) GetProcAddress(library, "grpc_ssl_credentials_create_ex");
402
- grpc_call_credentials_release_import = (grpc_call_credentials_release_type) GetProcAddress(library, "grpc_call_credentials_release");
403
403
  grpc_composite_channel_credentials_create_import = (grpc_composite_channel_credentials_create_type) GetProcAddress(library, "grpc_composite_channel_credentials_create");
404
404
  grpc_composite_call_credentials_create_import = (grpc_composite_call_credentials_create_type) GetProcAddress(library, "grpc_composite_call_credentials_create");
405
405
  grpc_google_compute_engine_credentials_create_import = (grpc_google_compute_engine_credentials_create_type) GetProcAddress(library, "grpc_google_compute_engine_credentials_create");
@@ -335,10 +335,13 @@ extern grpc_ssl_session_cache_destroy_type grpc_ssl_session_cache_destroy_import
335
335
  typedef grpc_arg(*grpc_ssl_session_cache_create_channel_arg_type)(grpc_ssl_session_cache* cache);
336
336
  extern grpc_ssl_session_cache_create_channel_arg_type grpc_ssl_session_cache_create_channel_arg_import;
337
337
  #define grpc_ssl_session_cache_create_channel_arg grpc_ssl_session_cache_create_channel_arg_import
338
+ typedef void(*grpc_call_credentials_release_type)(grpc_call_credentials* creds);
339
+ extern grpc_call_credentials_release_type grpc_call_credentials_release_import;
340
+ #define grpc_call_credentials_release grpc_call_credentials_release_import
338
341
  typedef void(*grpc_channel_credentials_release_type)(grpc_channel_credentials* creds);
339
342
  extern grpc_channel_credentials_release_type grpc_channel_credentials_release_import;
340
343
  #define grpc_channel_credentials_release grpc_channel_credentials_release_import
341
- typedef grpc_channel_credentials*(*grpc_google_default_credentials_create_type)(void);
344
+ typedef grpc_channel_credentials*(*grpc_google_default_credentials_create_type)(grpc_call_credentials* call_credentials);
342
345
  extern grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import;
343
346
  #define grpc_google_default_credentials_create grpc_google_default_credentials_create_import
344
347
  typedef void(*grpc_set_ssl_roots_override_callback_type)(grpc_ssl_roots_override_callback cb);
@@ -350,9 +353,6 @@ extern grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import;
350
353
  typedef grpc_channel_credentials*(*grpc_ssl_credentials_create_ex_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, const grpc_ssl_verify_peer_options* verify_options, void* reserved);
351
354
  extern grpc_ssl_credentials_create_ex_type grpc_ssl_credentials_create_ex_import;
352
355
  #define grpc_ssl_credentials_create_ex grpc_ssl_credentials_create_ex_import
353
- typedef void(*grpc_call_credentials_release_type)(grpc_call_credentials* creds);
354
- extern grpc_call_credentials_release_type grpc_call_credentials_release_import;
355
- #define grpc_call_credentials_release grpc_call_credentials_release_import
356
356
  typedef grpc_channel_credentials*(*grpc_composite_channel_credentials_create_type)(grpc_channel_credentials* channel_creds, grpc_call_credentials* call_creds, void* reserved);
357
357
  extern grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import;
358
358
  #define grpc_composite_channel_credentials_create grpc_composite_channel_credentials_create_import
@@ -14,5 +14,5 @@
14
14
 
15
15
  # GRPC contains the General RPC module.
16
16
  module GRPC
17
- VERSION = '1.31.1'
17
+ VERSION = '1.32.0.pre1'
18
18
  end
@@ -50,6 +50,16 @@ describe GRPC::Core::ChannelCredentials do
50
50
  blk = proc { ChannelCredentials.new(nil) }
51
51
  expect(&blk).not_to raise_error
52
52
  end
53
+
54
+ it 'fails gracefully with constructed with a nil private key' do
55
+ blk = proc { GRPC::Core::ChannelCredentials.new(nil, nil, '') }
56
+ expect(&blk).to raise_error
57
+ end
58
+
59
+ it 'fails gracefully with constructed with a nil cert chain' do
60
+ blk = proc { GRPC::Core::ChannelCredentials.new(nil, '', nil) }
61
+ expect(&blk).to raise_error
62
+ end
53
63
  end
54
64
 
55
65
  describe '#compose' do
@@ -43,6 +43,16 @@ describe GRPC::ActiveCall do
43
43
  @server = new_core_server_for_testing(nil)
44
44
  server_port = @server.add_http2_port(host, :this_port_is_insecure)
45
45
  @server.start
46
+ @received_rpcs_queue = Queue.new
47
+ @server_thread = Thread.new do
48
+ begin
49
+ received_rpc = @server.request_call
50
+ rescue GRPC::Core::CallError, StandardError => e
51
+ # enqueue the exception in this case as a way to indicate the error
52
+ received_rpc = e
53
+ end
54
+ @received_rpcs_queue.push(received_rpc)
55
+ end
46
56
  @ch = GRPC::Core::Channel.new("0.0.0.0:#{server_port}", nil,
47
57
  :this_channel_is_insecure)
48
58
  end
@@ -50,6 +60,7 @@ describe GRPC::ActiveCall do
50
60
  after(:each) do
51
61
  @server.shutdown_and_notify(deadline)
52
62
  @server.close
63
+ @server_thread.join
53
64
  end
54
65
 
55
66
  describe 'restricted view methods' do
@@ -105,7 +116,7 @@ describe GRPC::ActiveCall do
105
116
  client_call.remote_send(msg)
106
117
 
107
118
  # check that server rpc new was received
108
- recvd_rpc = @server.request_call
119
+ recvd_rpc = @received_rpcs_queue.pop
109
120
  expect(recvd_rpc).to_not eq nil
110
121
  recvd_call = recvd_rpc.call
111
122
 
@@ -130,7 +141,7 @@ describe GRPC::ActiveCall do
130
141
  client_call.remote_send(msg)
131
142
 
132
143
  # confirm that the message was marshalled
133
- recvd_rpc = @server.request_call
144
+ recvd_rpc = @received_rpcs_queue.pop
134
145
  recvd_call = recvd_rpc.call
135
146
  server_ops = {
136
147
  CallOps::SEND_INITIAL_METADATA => nil
@@ -160,7 +171,7 @@ describe GRPC::ActiveCall do
160
171
  call.run_batch(CallOps::SEND_CLOSE_FROM_CLIENT => nil) if f == 1
161
172
 
162
173
  # confirm that the message was marshalled
163
- recvd_rpc = @server.request_call
174
+ recvd_rpc = @received_rpcs_queue.pop
164
175
  recvd_call = recvd_rpc.call
165
176
  server_ops = {
166
177
  CallOps::SEND_INITIAL_METADATA => nil
@@ -321,7 +332,7 @@ describe GRPC::ActiveCall do
321
332
  call = make_test_call
322
333
  metadata = { k1: 'v1', k2: 'v2' }
323
334
  ActiveCall.client_invoke(call, metadata)
324
- recvd_rpc = @server.request_call
335
+ recvd_rpc = @received_rpcs_queue.pop
325
336
  recvd_call = recvd_rpc.call
326
337
  expect(recvd_call).to_not be_nil
327
338
  expect(recvd_rpc.metadata).to_not be_nil
@@ -339,7 +350,7 @@ describe GRPC::ActiveCall do
339
350
  call = make_test_call
340
351
  ActiveCall.client_invoke(call)
341
352
 
342
- recvd_rpc = @server.request_call
353
+ recvd_rpc = @received_rpcs_queue.pop
343
354
  server_call = ActiveCall.new(
344
355
  recvd_rpc.call,
345
356
  @pass_through,
@@ -405,7 +416,7 @@ describe GRPC::ActiveCall do
405
416
  client_call = make_test_call
406
417
  ActiveCall.client_invoke(client_call)
407
418
 
408
- recvd_rpc = @server.request_call
419
+ recvd_rpc = @received_rpcs_queue.pop
409
420
  recvd_call = recvd_rpc.call
410
421
 
411
422
  server_call = ActiveCall.new(
@@ -575,7 +586,7 @@ describe GRPC::ActiveCall do
575
586
  @client_call = make_test_call
576
587
  @client_call.run_batch(CallOps::SEND_INITIAL_METADATA => {})
577
588
 
578
- recvd_rpc = @server.request_call
589
+ recvd_rpc = @received_rpcs_queue.pop
579
590
  recvd_call = recvd_rpc.call
580
591
  @server_call = ActiveCall.new(
581
592
  recvd_call,
@@ -654,7 +665,7 @@ describe GRPC::ActiveCall do
654
665
  end
655
666
 
656
667
  def expect_server_to_be_invoked(**kw)
657
- recvd_rpc = @server.request_call
668
+ recvd_rpc = @received_rpcs_queue.pop
658
669
  expect(recvd_rpc).to_not eq nil
659
670
  recvd_call = recvd_rpc.call
660
671
  recvd_call.run_batch(CallOps::SEND_INITIAL_METADATA => kw)
@@ -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_