srctree

Robin Linden parent 04bc71a3 8a6972c0
util: Nuke now-unused Overloaded visitor helper

Writing regular operator()(Visited const &) {} visitors isn't much morework than using this and plays a lot nicer w/ clang-format, so no pointin keeping this around.

inlinesplit
ev/null added: 2, removed: 54, total 0
@@ -1,21 +0,0 @@
// SPDX-FileCopyrightText: 2021 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
#ifndef UTIL_OVERLOADED_H_
#define UTIL_OVERLOADED_H_
 
namespace util {
 
template<class... Ts>
struct Overloaded : Ts... {
using Ts::operator()...;
};
 
// Not needed as of C++20, but Clang won't work without it.
template<class... Ts>
Overloaded(Ts...) -> Overloaded<Ts...>;
 
} // namespace util
 
#endif
 
ev/null added: 2, removed: 54, total 0
@@ -1,31 +0,0 @@
// SPDX-FileCopyrightText: 2022-2023 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
#include "util/overloaded.h"
 
#include "etest/etest.h"
 
#include <cstdint>
#include <string_view>
#include <variant>
 
using namespace std::literals;
using etest::expect_eq;
using util::Overloaded;
 
int main() {
etest::test("it does what it should", [] {
auto visitor = Overloaded{
[](bool) { return "bool"sv; },
[](std::int32_t) { return "int32_t"sv; },
[](std::int64_t) { return "int64_t"sv; },
};
 
expect_eq("bool"sv, std::visit(visitor, std::variant<bool>(true)));
expect_eq("int32_t"sv, std::visit(visitor, std::variant<std::int32_t>(1)));
expect_eq("int64_t"sv, std::visit(visitor, std::variant<std::int64_t>(1)));
});
 
return etest::run_all_tests();
}