aboutsummaryrefslogtreecommitdiff
path: root/absl/functional/overload.h
diff options
context:
space:
mode:
authorVitaly Goldshteyn <goldvitaly@google.com>2024-03-06 02:38:50 -0800
committerCopybara-Service <copybara-worker@google.com>2024-03-06 02:39:47 -0800
commit6bf3c73fdfeb62733d2a0f81b9846ff77f3a3b9f (patch)
tree674d88886bca7c1407310a8d6691c07c6902413e /absl/functional/overload.h
parent8dc90ff07402cd027daec520bb77f46e51855889 (diff)
downloadabseil-6bf3c73fdfeb62733d2a0f81b9846ff77f3a3b9f.tar.gz
abseil-6bf3c73fdfeb62733d2a0f81b9846ff77f3a3b9f.tar.bz2
abseil-6bf3c73fdfeb62733d2a0f81b9846ff77f3a3b9f.zip
Document and test ability to use absl::Overload with generic lambdas.
PiperOrigin-RevId: 613141617 Change-Id: Ife68495d4a5951b734db7407fb99686cf45a5133
Diffstat (limited to 'absl/functional/overload.h')
-rw-r--r--absl/functional/overload.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/absl/functional/overload.h b/absl/functional/overload.h
index 4651f14b..732795fc 100644
--- a/absl/functional/overload.h
+++ b/absl/functional/overload.h
@@ -35,7 +35,14 @@
// [](double) -> absl::string_view { return "double"; }),
// v) == "int");
//
-// Note: This requires C++17.
+// One of the lambda may specify overload for several types via generic lambda.
+//
+// absl::variant<std::string, int32_t, int64_t> v(int32_t{1});
+// assert(std::visit(absl::Overload(
+// [](const std::string& s) { return s.size(); },
+// [](const auto& s) { return sizeof(s); }), v) == 4);
+//
+// Note: absl::Overload requires C++17.
#ifndef ABSL_FUNCTIONAL_OVERLOAD_H_
#define ABSL_FUNCTIONAL_OVERLOAD_H_