// Copyright 2022 Huawei Cloud Computing Technology 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 INCLUDED_SRC_UTILS_CPP_CONCEPTS_HPP #define INCLUDED_SRC_UTILS_CPP_CONCEPTS_HPP #include #include #include #include #include #include #include template concept ContainsString = requires { typename T::value_type; } and std::same_as; template concept HasSize = requires(T const c) { std::same_as; }; template concept InputIterableContainer = requires(T const c) { std::input_iterator; std::input_iterator; }; template concept OutputIterableContainer = requires(T c) { InputIterableContainer; std::output_iterator; }; template concept InputIterableStringContainer = InputIterableContainer and ContainsString; // TODO(modernize): remove this once we require clang version >= 14.0.0 template concept ClockHasFromSys = requires(std::chrono::time_point const tp) { T::from_sys(tp); }; // TODO(modernize): remove this once we require clang version >= 14.0.0 template concept ClockHasFromTime = requires(std::time_t const t) { T::from_time_t(t); }; template concept StrMapConstForwardIterator = requires(T const c) { { std::remove_reference_t{(*c).first} } -> std::same_as; }; #endif // INCLUDED_SRC_UTILS_CPP_CONCEPTS_HPP