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