aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/overloaded.h
diff options
context:
space:
mode:
authorMikhail Borisov <borisov.mikhail@gmail.com>2022-02-10 16:45:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:39 +0300
commita6a92afe03e02795227d2641b49819b687f088f8 (patch)
treef6984a1d27d5a7ec88a6fdd6e20cd5b7693b6ece /util/generic/overloaded.h
parentc6dc8b8bd530985bc4cce0137e9a5de32f1087cb (diff)
downloadydb-a6a92afe03e02795227d2641b49819b687f088f8.tar.gz
Restoring authorship annotation for Mikhail Borisov <borisov.mikhail@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/generic/overloaded.h')
-rw-r--r--util/generic/overloaded.h84
1 files changed, 42 insertions, 42 deletions
diff --git a/util/generic/overloaded.h b/util/generic/overloaded.h
index 96a97e44bc..eb9b58cad4 100644
--- a/util/generic/overloaded.h
+++ b/util/generic/overloaded.h
@@ -1,52 +1,52 @@
#pragma once
-/**
+/**
* Construct an ad-hoc object with an overloaded `operator()`.
- *
+ *
* Typically used with lambdas to construct type-matching visitors for e.g. std::variant:
- * ```
+ * ```
* std::variant<int, void*, TString> var;
- * Visit(TOverloaded{
- * [](int val) { Cerr << "int: " << val; },
- * [](void* val) { Cerr << "ptr: " << val; },
- * [](const TString& val) { Cerr << "str: " << val; },
- * }, var);
- * ```
- *
- * *** IMPORTANT NOTE (IMPLICIT ARGUMENT CONVERSIONS) ***
- *
- * Since the resulting objects use regular overloaded method resolution rules,
- * methods may be called by inexact matches (causing implicit casts), hence this
- * implementation does not guarantee exhaustiveness of cases.
- *
- * For example, the following code will compile and run by casting all values to
- * double:
- * ```
+ * Visit(TOverloaded{
+ * [](int val) { Cerr << "int: " << val; },
+ * [](void* val) { Cerr << "ptr: " << val; },
+ * [](const TString& val) { Cerr << "str: " << val; },
+ * }, var);
+ * ```
+ *
+ * *** IMPORTANT NOTE (IMPLICIT ARGUMENT CONVERSIONS) ***
+ *
+ * Since the resulting objects use regular overloaded method resolution rules,
+ * methods may be called by inexact matches (causing implicit casts), hence this
+ * implementation does not guarantee exhaustiveness of cases.
+ *
+ * For example, the following code will compile and run by casting all values to
+ * double:
+ * ```
* std::variant<int, double, char> var;
- * Visit(TOverloaded{
- * [](double val) { Cerr << "dbl: " << val; },
- * }, var);
- * ```
- *
- * If cases may be ambigous or specific type-matching logic is required,
- * a verbose `if constexpr`-based version would be preferred:
- * ```
+ * Visit(TOverloaded{
+ * [](double val) { Cerr << "dbl: " << val; },
+ * }, var);
+ * ```
+ *
+ * If cases may be ambigous or specific type-matching logic is required,
+ * a verbose `if constexpr`-based version would be preferred:
+ * ```
* std::variant<int, double, char> var;
- * Visit([](auto&& val) {
- * using T = std::decay_t<decltype(val)>;
- * if constexpr (std::is_same_v<T, int>) {
- * Cerr << "int: " << val;
- * } else if constexpr (std::is_same_v<T, double>) {
- * Cerr << "dbl: " << val;
- * } else if constexpr (std::is_same_v<T, char>) {
- * Cerr << "chr: " << val;
- * } else {
- * static_assert(TDependentFalse<T>, "unexpected type");
- * }
- * }, var);
- * ```
- */
-
+ * Visit([](auto&& val) {
+ * using T = std::decay_t<decltype(val)>;
+ * if constexpr (std::is_same_v<T, int>) {
+ * Cerr << "int: " << val;
+ * } else if constexpr (std::is_same_v<T, double>) {
+ * Cerr << "dbl: " << val;
+ * } else if constexpr (std::is_same_v<T, char>) {
+ * Cerr << "chr: " << val;
+ * } else {
+ * static_assert(TDependentFalse<T>, "unexpected type");
+ * }
+ * }, var);
+ * ```
+ */
+
template <class... Fs>
struct TOverloaded: Fs... {
using Fs::operator()...;