VTK  9.3.0
vtkMeta.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
4 #ifndef vtkMeta_h
5 #define vtkMeta_h
6 
7 #include "vtkABINamespace.h"
8 
9 #include <type_traits>
10 #include <utility>
11 
18 // Forward decs for StripPointers:
19 VTK_ABI_NAMESPACE_BEGIN
20 template <typename ArrayType>
21 class vtkNew;
22 template <typename ArrayType>
23 class vtkSmartPointer;
24 template <typename ArrayType>
25 class vtkWeakPointer;
26 VTK_ABI_NAMESPACE_END
27 
28 namespace vtk
29 {
30 namespace detail
31 {
32 VTK_ABI_NAMESPACE_BEGIN
33 
34 //------------------------------------------------------------------------------
35 // Strip vtkNew, vtkSmartPointer, etc from a type.
36 template <typename T>
38 {
39  using type = T;
40 };
41 
42 template <typename T>
43 struct StripPointers<T*>
44 {
45  using type = T;
46 };
47 
48 template <typename ArrayType>
49 struct StripPointers<vtkNew<ArrayType>>
50 {
51  using type = ArrayType;
52 };
53 
54 template <typename ArrayType>
55 struct StripPointers<vtkSmartPointer<ArrayType>>
56 {
57  using type = ArrayType;
58 };
59 
60 template <typename ArrayType>
61 struct StripPointers<vtkWeakPointer<ArrayType>>
62 {
63  using type = ArrayType;
64 };
65 
66 //------------------------------------------------------------------------------
67 // Test if a type is defined (true) or just forward declared (false).
68 template <typename T>
69 struct IsComplete
70 {
71 private:
72  // Can't take the sizeof an incomplete class.
73  template <typename U, std::size_t = sizeof(U)>
74  static std::true_type impl(U*);
75  static std::false_type impl(...);
76  using bool_constant = decltype(impl(std::declval<T*>()));
77 
78 public:
79  static constexpr bool value = bool_constant::value;
80 };
81 
82 VTK_ABI_NAMESPACE_END
83 }
84 } // end namespace vtk::detail
85 
86 #endif // vtkMeta_h
87 
88 // VTK-HeaderTest-Exclude: vtkMeta.h
Allocate and hold a VTK object.
Definition: vtkNew.h:51
Hold a reference to a vtkObjectBase instance.
a weak reference to a vtkObject.
@ value
Definition: vtkX3D.h:220
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
static constexpr bool value
Definition: vtkMeta.h:79