/* * Copyright (c) 2025 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 COMMON_INTERFACES_OBJECTS_TRAITS_H #define COMMON_INTERFACES_OBJECTS_TRAITS_H #include "common_interfaces/objects/base_object.h" #include namespace common::objects_traits { template constexpr bool is_heap_object_v = std::is_base_of_v>; // WriteBarrier: void (void*, size_t, U) template constexpr bool is_write_barrier_callable_v = std::is_invocable_r_v; // ReadBarrier: U (void*, size_t) template constexpr bool is_read_barrier_callable_v = is_heap_object_v && std::is_invocable_v && std::is_convertible_v, U>; // Allocator: U (size_t, CommonType) template constexpr bool is_allocate_callable_v = is_heap_object_v && std::is_invocable_r_v; // ---- enable_if_is_* traits ---- template using enable_if_is_write_barrier = std::enable_if_t, int>; template using enable_if_is_read_barrier = std::enable_if_t, int>; template using enable_if_is_allocate = std::enable_if_t, int>; template struct is_std_vector_of : std::false_type {}; template struct is_std_vector_of, T> : std::true_type {}; template constexpr bool is_std_vector_of_v = is_std_vector_of::value; template using get_allocator_type_t = typename std::decay_t::allocator_type; template using rebind_alloc_t = typename std::allocator_traits::template rebind_alloc; template using vector_with_same_alloc_t = std::vector, NewT>>; } // namespace common::objects_traits #endif //COMMON_INTERFACES_OBJECTS_TRAITS_H