/* * Copyright (c) 2022 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 TRAITS_UTIL_H #define TRAITS_UTIL_H #include #include #include namespace Updater { namespace Detail { template inline constexpr bool G_IS_NUM = std::is_integral_v && !std::is_same_v; template inline constexpr bool G_IS_BOOL = std::is_same_v; template inline constexpr bool G_IS_STR = (std::is_same_v> || std::is_same_v> || std::is_same_v); template inline constexpr bool G_IS_PRINTABLE = (G_IS_NUM || G_IS_BOOL || G_IS_STR); template inline constexpr bool G_IS_BASE_TYPE = (G_IS_NUM || G_IS_BOOL || G_IS_STR); template struct IsVector : std::false_type {}; template struct IsVector> : std::true_type {}; template constexpr bool G_IS_VECTOR = IsVector::value; template using isMatch = typename std::enable_if_t; template using RemoveCvRef = std::remove_cv_t>; template struct StandardTypeHelper { static_assert(G_IS_BASE_TYPE); using type = std::conditional_t, int, std::conditional_t, std::string, bool>>; }; template using StandardType = typename StandardTypeHelper::type; template using OptStandardType = std::optional>>; template inline auto &Get(T &&...t) { return std::get(std::forward_as_tuple(t...)); } } } #endif