unlogic
Loading...
Searching...
No Matches
overload.h
Go to the documentation of this file.
1//
2// Created by Nathan on 11/25/2024.
3//
4
5#ifndef OVERLOAD_H
6#define OVERLOAD_H
7
8namespace unlogic
9{
10 /*
11 * Helper for std::visit provided by Andreas Fertig.
12 * Apple-Clang 15 isn't C++23 compliant enough for the prettier solution, so C++17 style it is.
13 * https://andreasfertig.blog/2023/07/visiting-a-stdvariant-safely/
14 */
15 template<class...>
16 constexpr bool always_false_v = false;
17
18 template<class... Ts>
19 struct overload : Ts...
20 {
21 using Ts::operator()...;
22
23 template<typename T>
24 constexpr void operator()(T) const
25 {
26 static_assert(always_false_v<T>, "Unsupported type");
27 }
28 };
29
30 template<class... Ts>
31 overload(Ts...) -> overload<Ts...>;
32} // namespace unlogic
33
34#endif // OVERLOAD_H
constexpr bool always_false_v
Definition overload.h:16
UniqueNode unique_node(Args &&... args)
Definition Node.h:144
constexpr void operator()(T) const
Definition overload.h:24