OpenTTD Source 20250205-master-gfd85ab1e2c
convertible_through_base.hpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef CONVERTIBLE_THROUGH_BASE_HPP
11#define CONVERTIBLE_THROUGH_BASE_HPP
12
18template <typename T>
19concept ConvertibleThroughBase = requires(T const a) {
20 typename T::BaseType;
21 { a.base() } noexcept -> std::convertible_to<int64_t>;
22};
23
29template <typename T, typename TTo>
30concept ConvertibleThroughBaseOrTo = std::is_convertible_v<T, TTo> || ConvertibleThroughBase<T>;
31
32#endif /* CONVERTIBLE_THROUGH_BASE_HPP */
Type is convertible to TTo, either directly or through ConvertibleThroughBase.
A type is considered 'convertible through base()' when it has a 'base()' function that returns someth...