• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2024 Google LLC.  All rights reserved.
3 //
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file or at
6 // https://developers.google.com/open-source/licenses/bsd
7 
8 #ifndef GOOGLE_PROTOBUF_HPB_TEMPLATE_HELP_H__
9 #define GOOGLE_PROTOBUF_HPB_TEMPLATE_HELP_H__
10 
11 #include <type_traits>
12 
13 #include "google/protobuf/hpb/ptr.h"
14 
15 namespace hpb {
16 namespace internal {
17 
18 template <typename T>
19 struct RemovePtr;
20 
21 template <typename T>
22 struct RemovePtr<Ptr<T>> {
23   using type = T;
24 };
25 
26 template <typename T>
27 struct RemovePtr<T*> {
28   using type = T;
29 };
30 
31 template <typename T>
32 using RemovePtrT = typename RemovePtr<T>::type;
33 
34 template <typename T, typename U = RemovePtrT<T>,
35           typename = std::enable_if_t<!std::is_const_v<U>>>
36 using PtrOrRaw = T;
37 
38 template <typename T>
39 using EnableIfHpbClass = std::enable_if_t<
40     std::is_base_of<typename T::Access, T>::value &&
41     std::is_base_of<typename T::Access, typename T::ExtendableType>::value>;
42 
43 template <typename T>
44 using EnableIfMutableProto = std::enable_if_t<!std::is_const<T>::value>;
45 
46 template <typename T, typename T2>
47 using add_const_if_T_is_const =
48     std::conditional_t<std::is_const_v<T>, const T2, T2>;
49 
50 }  // namespace internal
51 }  // namespace hpb
52 
53 #endif  // GOOGLE_PROTOBUF_HPB_TEMPLATE_HELP_H__
54