// Copyright 2011 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef BASE_TEMPLATE_UTIL_H_ #define BASE_TEMPLATE_UTIL_H_ #include #include #include #include #include #include "base/compiler_specific.h" namespace base { namespace internal { // Used to detect whether the given type is an iterator. This is normally used // with std::enable_if to provide disambiguation for functions that take // templatzed iterators as input. template struct is_iterator : std::false_type {}; template struct is_iterator< T, std::void_t::iterator_category>> : std::true_type {}; // Helper to express preferences in an overload set. If more than one overload // are available for a given set of parameters the overload with the higher // priority will be chosen. template struct priority_tag : priority_tag {}; template <> struct priority_tag<0> {}; } // namespace internal namespace internal { // The indirection with std::is_enum is required, because instantiating // std::underlying_type_t when T is not an enum is UB prior to C++20. template > struct IsScopedEnumImpl : std::false_type {}; template struct IsScopedEnumImpl=*/true> : std::negation>> {}; } // namespace internal // Implementation of C++23's std::is_scoped_enum // // Reference: https://en.cppreference.com/w/cpp/types/is_scoped_enum template struct is_scoped_enum : internal::IsScopedEnumImpl {}; } // namespace base #endif // BASE_TEMPLATE_UTIL_H_