/* ***************************************************************************** * kblib is a general utility library for C++14 and C++17, intended to provide * performant high-level abstractions and more expressive ways to do simple * things. * * Copyright (c) 2021 killerbee * * This program 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, either version 3 of the License, or * (at your option) any later version. * * This program 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. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * ****************************************************************************/ /** * @file * @brief Contains some type traits not in the standard library that are useful * in the implementation of kblib. * * @author killerbee * @date 2019-2021 * @copyright GNU General Public Licence v3.0 */ #ifndef KBLIB_TRAITS_H_INCLUDED_ #define KBLIB_TRAITS_H_INCLUDED_ #include "fakestd.h" #include "tdecl.h" #include #include #include #include namespace KBLIB_NS { // contains_types adapted from code by Maarten Bamelis, // https://stackoverflow.com/a/42581257/1924641 /** * @brief Determines if T is a type in Tuple, which must be a std::tuple. */ template struct contains_type; template struct contains_type, U> : contains_type, U> {}; template struct contains_type, T> : std::true_type {}; template struct contains_type, T> : std::false_type {}; template KBLIB_CONSTANT_V contains_type_v = contains_type::value; /** * @brief Determines if Lhs contains all of the types in Rhs, where both are * std::tuples. */ template struct contains_types; template struct contains_types> : std::integral_constant< bool, contains_type::value and contains_types>::value> {}; template struct contains_types> : std::true_type {}; template KBLIB_CONSTANT_V contains_types_v = contains_types::value; template struct list_as_tuple; template