VTK  9.1.0
vtkMeta.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkMeta.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
15
16#ifndef vtkMeta_h
17#define vtkMeta_h
18
19#include <type_traits>
20#include <utility>
21
28// Forward decs for StripPointers:
29template <typename ArrayType>
30class vtkNew;
31template <typename ArrayType>
32class vtkSmartPointer;
33template <typename ArrayType>
34class vtkWeakPointer;
35
36namespace vtk
37{
38namespace detail
39{
40
41//------------------------------------------------------------------------------
42// Strip vtkNew, vtkSmartPointer, etc from a type.
43template <typename T>
45{
46 using type = T;
47};
48
49template <typename T>
50struct StripPointers<T*>
51{
52 using type = T;
53};
54
55template <typename ArrayType>
56struct StripPointers<vtkNew<ArrayType>>
57{
58 using type = ArrayType;
59};
60
61template <typename ArrayType>
63{
64 using type = ArrayType;
65};
66
67template <typename ArrayType>
68struct StripPointers<vtkWeakPointer<ArrayType>>
69{
70 using type = ArrayType;
71};
72
73//------------------------------------------------------------------------------
74// Test if a type is defined (true) or just forward declared (false).
75template <typename T>
77{
78private:
79 // Can't take the sizeof an incomplete class.
80 template <typename U, std::size_t = sizeof(U)>
81 static std::true_type impl(U*);
82 static std::false_type impl(...);
83 using bool_constant = decltype(impl(std::declval<T*>()));
84
85public:
86 static constexpr bool value = bool_constant::value;
87};
88
89}
90} // end namespace vtk::detail
91
92#endif // vtkMeta_h
93
94// VTK-HeaderTest-Exclude: vtkMeta.h
Allocate and hold a VTK object.
Definition: vtkNew.h:165
Hold a reference to a vtkObjectBase instance.
a weak reference to a vtkObject.
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
static constexpr bool value
Definition: vtkMeta.h:86