xref: /aosp_15_r20/external/cronet/base/allocator/dispatcher/internal/tools.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2022 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_ALLOCATOR_DISPATCHER_INTERNAL_TOOLS_H_
6 #define BASE_ALLOCATOR_DISPATCHER_INTERNAL_TOOLS_H_
7 
8 #include <cstddef>
9 
10 namespace base::allocator::dispatcher::internal {
11 
LessEqual(size_t lhs,size_t rhs)12 constexpr bool LessEqual(size_t lhs, size_t rhs) {
13   return lhs <= rhs;
14 }
15 
Equal(size_t lhs,size_t rhs)16 constexpr bool Equal(size_t lhs, size_t rhs) {
17   return lhs == rhs;
18 }
19 
20 struct IsValidObserver {
21   template <typename T>
operatorIsValidObserver22   constexpr bool operator()(T const* ptr) const noexcept {
23     return ptr != nullptr;
24   }
25 };
26 
27 }  // namespace base::allocator::dispatcher::internal
28 
29 #endif  // BASE_ALLOCATOR_DISPATCHER_INTERNAL_TOOLS_H_
30