/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MAPLE_UTIL_INCLUDE_UTILS_META_H #define MAPLE_UTIL_INCLUDE_UTILS_META_H #include namespace maple { namespace utils { template struct meta_and : public std::conditional_t { }; template struct meta_or : public std::conditional_t { }; template struct meta_not : public std::integral_constant(T::value)>::type { }; template struct is_signed; template struct is_signed : public std::is_signed::type { }; template struct is_signed : public meta_and, std::is_signed>::type { }; template constexpr bool is_signed_v = is_signed::value; template struct is_unsigned; template struct is_unsigned : public std::is_unsigned::type { }; template struct is_unsigned : public meta_and, std::is_unsigned>::type { }; template constexpr bool is_unsigned_v = is_unsigned::value; template struct is_same_sign : public meta_or, is_unsigned>::type { }; template struct is_diff_sign : public meta_not>::type { }; template struct is_pointer; template struct is_pointer : public std::is_pointer::type { }; template struct is_pointer : public meta_and, is_pointer>::type { }; template constexpr bool is_pointer_v = is_pointer::value; template struct const_of : public meta_and, std::is_same, U>>::type { }; template constexpr bool const_of_v = const_of::value; template struct is_ncv_same : public std::is_same, std::remove_cv_t>::type { }; template constexpr bool is_ncv_same_v = is_ncv_same::value; namespace ptr { template >> struct const_of : public utils::const_of, std::remove_pointer_t>::type { }; template >> constexpr bool const_of_v = const_of::value; template >> struct is_ncv_same : public utils::is_ncv_same, std::remove_pointer_t>::type { }; template >> constexpr bool is_ncv_same_v = is_ncv_same::value; } // namespace ptr } // namespace utils } // namespace maple #endif // MAPLE_UTIL_INCLUDE_UTILS_META_H