/** * Copyright (c) 2021-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 PANDA_LIBPANDABASE_CONCEPTS_H_ #define PANDA_LIBPANDABASE_CONCEPTS_H_ #include namespace panda { /// Iterable concept template struct is_iterable : public std::false_type {}; // NOLINT(readability-identifier-naming) template struct is_iterable< // NOLINT(readability-identifier-naming) T, std::void_t().begin()), decltype(std::declval().end())>> : public std::true_type {}; template // NOLINTNEXTLINE(readability-identifier-naming, misc-definitions-in-headers) constexpr bool is_iterable_v = is_iterable::value; /// Random access iterable concept template struct is_random_access_iterable // NOLINT(readability-identifier-naming) : public std::bool_constant && std::is_same_v::iterator_category, std::random_access_iterator_tag>> {}; template // NOLINTNEXTLINE(readability-identifier-naming, misc-definitions-in-headers) constexpr bool is_random_access_iterable_v = is_random_access_iterable::value; /// Forward iterable concept template struct is_forward_iterable // NOLINT(readability-identifier-naming) : public std::bool_constant && std::is_same_v::iterator_category, std::forward_iterator_tag>> {}; template // NOLINTNEXTLINE(readability-identifier-naming, misc-definitions-in-headers) constexpr bool is_forward_iterable_v = is_forward_iterable::value; /// Vectorable concept template struct is_vectorable : public std::false_type {}; // NOLINT(readability-identifier-naming) template struct is_vectorable< // NOLINT(readability-identifier-naming) V, std::void_t().size()), decltype(std::declval().data())>> : public std::bool_constant> {}; template // NOLINTNEXTLINE(readability-identifier-naming, misc-definitions-in-headers) constexpr bool is_vectorable_v = is_vectorable::value; /// Stringable concept template struct is_stringable : public std::false_type {}; // NOLINT(readability-identifier-naming) template struct is_stringable< // NOLINT(readability-identifier-naming) S, std::void_t().length()), decltype(std::declval().data())>> : public std::bool_constant> {}; template // NOLINTNEXTLINE(readability-identifier-naming, misc-definitions-in-headers) constexpr bool is_stringable_v = is_stringable::value; /// Hash mappable concept template struct is_hash_mappable : public std::false_type {}; // NOLINT(readability-identifier-naming) template struct is_hash_mappable< // NOLINT(readability-identifier-naming) HM, std::void_t().size())>> : public std::bool_constant> {}; template // NOLINTNEXTLINE(readability-identifier-naming, misc-definitions-in-headers) constexpr bool is_hash_mappable_v = is_hash_mappable::value; /** * Added in C++20 */ /// Checks whether T is an array type of unknown bound template // NOLINTNEXTLINE(readability-identifier-naming) struct is_unbounded_array : public std::false_type {}; template // NOLINTNEXTLINE(readability-identifier-naming, modernize-avoid-c-arrays) struct is_unbounded_array : public std::true_type {}; template // NOLINTNEXTLINE(readability-identifier-naming, misc-definitions-in-headers) constexpr bool is_unbounded_array_v = is_unbounded_array::value; /// Checks whether T is an array type of known bound template // NOLINTNEXTLINE(readability-identifier-naming) struct is_bounded_array : public std::false_type {}; template // NOLINTNEXTLINE(readability-identifier-naming, modernize-avoid-c-arrays) struct is_bounded_array : public std::true_type {}; template // NOLINTNEXTLINE(readability-identifier-naming, misc-definitions-in-headers) constexpr bool is_bounded_array_v = is_bounded_array::value; } // namespace panda #endif // PANDA_LIBPANDABASE_CONCEPTS_H_