From 3910827805a995f6766b7c149b0c7175d78bf54b Mon Sep 17 00:00:00 2001 From: cat Date: Thu, 26 Feb 2026 01:32:16 +0200 Subject: [PATCH] Moved concepts out of containers and several tweaks on concepts.hpp --- headers/Concepts.hpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 headers/Concepts.hpp diff --git a/headers/Concepts.hpp b/headers/Concepts.hpp new file mode 100644 index 0000000..187ecc3 --- /dev/null +++ b/headers/Concepts.hpp @@ -0,0 +1,34 @@ +/* + * SPDX-FileCopyrightText: Dora "cat" + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef GUARD_TOURMALINE_CONCEPTS_H +#define GUARD_TOURMALINE_CONCEPTS_H +#include +#include + +namespace Tourmaline::Concepts { +template +concept Hashable = std::equality_comparable && requires(T x) { + { std::hash{}(x) } -> std::convertible_to; +}; + +template +concept Either = std::same_as || std::same_as; + +// Oh C++ and your jank +template struct _opposite_of { + using type = std::conditional_t, Type2, Type1>; +}; + +template + requires Either +using OppositeOf = _opposite_of::type; + +} // namespace Tourmaline::Concepts +#endif