diff --git a/Modules/Core/Common/include/itkSTLConstContainerAdaptor.h b/Modules/Core/Common/include/itkSTLConstContainerAdaptor.h index 670c38e3f7c..b9ef269e1b2 100644 --- a/Modules/Core/Common/include/itkSTLConstContainerAdaptor.h +++ b/Modules/Core/Common/include/itkSTLConstContainerAdaptor.h @@ -36,7 +36,7 @@ namespace itk * Here's a usage example of STLContainerAdaptor * \code - itk::STLConstContainerAdaptor> vecAdaptor(aContainer); + itk::STLConstContainerAdaptor> vecAdaptor(aContainer); const std::vector & vec = vecAdaptor.GetSTLContainerRef(); // do things with vec ... \endcode diff --git a/Modules/Core/Common/include/itkVectorContainer.h b/Modules/Core/Common/include/itkVectorContainer.h index e32462d8458..0bcfbe09c0a 100644 --- a/Modules/Core/Common/include/itkVectorContainer.h +++ b/Modules/Core/Common/include/itkVectorContainer.h @@ -21,11 +21,14 @@ #include "itkObject.h" #include "itkObjectFactory.h" +#include // For is_void_v. #include #include namespace itk { +namespace detail +{ /** \class VectorContainer * \brief Define a front-end to the STL "vector" container that conforms to the * IndexedContainerInterface. @@ -561,6 +564,22 @@ class ITK_TEMPLATE_EXPORT VectorContainer , VectorType(first, last) {} }; +} // namespace detail + + +/** Alias template, allowing to use `itk::VectorContainer` without having to explicitly specify its + * `ElementIdentifier` type. + * + * The template parameters `T1` and `T2` allow specifying the index type and the element type, as follows: + * + * \tparam T1 The index type OR (when `T2` is `void`) the element type. + * + * \tparam T2 The element type OR `void`. When `T2` is `void`, the element type is specified by the first template + * argument (T1), and the index type will be `SizeValueType`. + */ +template +using VectorContainer = detail::VectorContainer, SizeValueType, T1>, + std::conditional_t, T1, T2>>; /** Makes a VectorContainer that has a copy of the specified `std::vector`. */ @@ -568,7 +587,7 @@ template auto MakeVectorContainer(std::vector stdVector) { - auto vectorContainer = VectorContainer::New(); + auto vectorContainer = VectorContainer::New(); vectorContainer->CastToSTLContainer() = std::move(stdVector); return vectorContainer; } diff --git a/Modules/Core/Common/include/itkVectorContainer.hxx b/Modules/Core/Common/include/itkVectorContainer.hxx index 6a658639036..a8fc5962093 100644 --- a/Modules/Core/Common/include/itkVectorContainer.hxx +++ b/Modules/Core/Common/include/itkVectorContainer.hxx @@ -20,7 +20,7 @@ #include "itkNumericTraits.h" -namespace itk +namespace itk::detail { template @@ -183,6 +183,6 @@ template void VectorContainer::Squeeze() {} -} // end namespace itk +} // namespace itk::detail #endif diff --git a/Modules/Core/Common/test/itkVectorContainerGTest.cxx b/Modules/Core/Common/test/itkVectorContainerGTest.cxx index 90b311b728c..148219b5a9a 100644 --- a/Modules/Core/Common/test/itkVectorContainerGTest.cxx +++ b/Modules/Core/Common/test/itkVectorContainerGTest.cxx @@ -27,9 +27,9 @@ using TestedElementIdentifierType = size_t; // Test template instantiations for various TElement template arguments: -template class itk::VectorContainer; -template class itk::VectorContainer; -template class itk::VectorContainer; +template class itk::detail::VectorContainer; +template class itk::detail::VectorContainer; +template class itk::detail::VectorContainer; namespace diff --git a/Modules/Core/Mesh/include/itkMesh.h b/Modules/Core/Mesh/include/itkMesh.h index 03580acfbdf..cb6949b903c 100644 --- a/Modules/Core/Mesh/include/itkMesh.h +++ b/Modules/Core/Mesh/include/itkMesh.h @@ -184,7 +184,7 @@ class ITK_TEMPLATE_EXPORT Mesh : public PointSet; + using CellsVectorContainer = typename itk::VectorContainer; using CellsVectorContainerPointer = typename CellsVectorContainer::Pointer; /** Used to support geometric operations on the toolkit. */ diff --git a/Modules/Core/SpatialObjects/include/itkBlobSpatialObject.h b/Modules/Core/SpatialObjects/include/itkBlobSpatialObject.h index 52bbd02dedd..cc2f36b0851 100644 --- a/Modules/Core/SpatialObjects/include/itkBlobSpatialObject.h +++ b/Modules/Core/SpatialObjects/include/itkBlobSpatialObject.h @@ -64,7 +64,7 @@ class ITK_TEMPLATE_EXPORT BlobSpatialObject : public PointBasedSpatialObject; + using PointContainerType = VectorContainer; using PointContainerPointer = SmartPointer; /** Method for creation through the object factory. */ diff --git a/Modules/Core/SpatialObjects/include/itkContourSpatialObject.h b/Modules/Core/SpatialObjects/include/itkContourSpatialObject.h index 50e71dea7de..938cad41022 100644 --- a/Modules/Core/SpatialObjects/include/itkContourSpatialObject.h +++ b/Modules/Core/SpatialObjects/include/itkContourSpatialObject.h @@ -87,7 +87,7 @@ class ITK_TEMPLATE_EXPORT ContourSpatialObject using typename Superclass::PointType; using typename Superclass::TransformType; using typename Superclass::BoundingBoxType; - using PointContainerType = VectorContainer; + using PointContainerType = VectorContainer; using PointContainerPointer = SmartPointer; using InterpolationMethodEnum = ContourSpatialObjectEnums::InterpolationMethod; diff --git a/Modules/Core/SpatialObjects/include/itkDTITubeSpatialObject.h b/Modules/Core/SpatialObjects/include/itkDTITubeSpatialObject.h index f8bc695f84b..d8e87b7c69f 100644 --- a/Modules/Core/SpatialObjects/include/itkDTITubeSpatialObject.h +++ b/Modules/Core/SpatialObjects/include/itkDTITubeSpatialObject.h @@ -56,7 +56,7 @@ class ITK_TEMPLATE_EXPORT DTITubeSpatialObject using typename Superclass::PointType; using typename Superclass::TransformType; using typename Superclass::SpatialObjectPointType; - using PointContainerType = VectorContainer; + using PointContainerType = VectorContainer; using PointContainerPointer = SmartPointer; using typename Superclass::VectorType; using typename Superclass::CovariantVectorType; diff --git a/Modules/Core/SpatialObjects/include/itkEllipseSpatialObject.h b/Modules/Core/SpatialObjects/include/itkEllipseSpatialObject.h index 66ce1ac5fa9..32c8eb9e810 100644 --- a/Modules/Core/SpatialObjects/include/itkEllipseSpatialObject.h +++ b/Modules/Core/SpatialObjects/include/itkEllipseSpatialObject.h @@ -49,7 +49,7 @@ class ITK_TEMPLATE_EXPORT EllipseSpatialObject : public SpatialObject; + using PointContainerType = VectorContainer; using PointContainerPointer = SmartPointer; using ArrayType = FixedArray; diff --git a/Modules/Core/SpatialObjects/include/itkLandmarkSpatialObject.h b/Modules/Core/SpatialObjects/include/itkLandmarkSpatialObject.h index 482068bbc1b..eaaad34606a 100644 --- a/Modules/Core/SpatialObjects/include/itkLandmarkSpatialObject.h +++ b/Modules/Core/SpatialObjects/include/itkLandmarkSpatialObject.h @@ -54,7 +54,7 @@ class ITK_TEMPLATE_EXPORT LandmarkSpatialObject : public PointBasedSpatialObject using typename Superclass::PointType; using typename Superclass::TransformType; using typename Superclass::BoundingBoxType; - using PointContainerType = VectorContainer; + using PointContainerType = VectorContainer; using PointContainerPointer = SmartPointer; /** Method for creation through the object factory. */ diff --git a/Modules/Core/SpatialObjects/include/itkLineSpatialObject.h b/Modules/Core/SpatialObjects/include/itkLineSpatialObject.h index bc141475332..cedf327e75e 100644 --- a/Modules/Core/SpatialObjects/include/itkLineSpatialObject.h +++ b/Modules/Core/SpatialObjects/include/itkLineSpatialObject.h @@ -60,7 +60,7 @@ class ITK_TEMPLATE_EXPORT LineSpatialObject using typename Superclass::PointType; using typename Superclass::TransformType; using typename Superclass::BoundingBoxType; - using PointContainerType = VectorContainer; + using PointContainerType = VectorContainer; using PointContainerPointer = SmartPointer; /** Method for creation through the object factory. */ diff --git a/Modules/Core/SpatialObjects/include/itkMeshSpatialObject.h b/Modules/Core/SpatialObjects/include/itkMeshSpatialObject.h index 02074d28481..1ccef3fea64 100644 --- a/Modules/Core/SpatialObjects/include/itkMeshSpatialObject.h +++ b/Modules/Core/SpatialObjects/include/itkMeshSpatialObject.h @@ -53,7 +53,7 @@ class ITK_TEMPLATE_EXPORT MeshSpatialObject : public SpatialObject; + using PointContainerType = VectorContainer; using PointContainerPointer = typename PointContainerType::Pointer; /** Method for creation through the object factory. */ diff --git a/Modules/Core/SpatialObjects/include/itkSpatialObject.h b/Modules/Core/SpatialObjects/include/itkSpatialObject.h index 54e832900fd..050bfaf498b 100644 --- a/Modules/Core/SpatialObjects/include/itkSpatialObject.h +++ b/Modules/Core/SpatialObjects/include/itkSpatialObject.h @@ -101,7 +101,7 @@ class ITK_TEMPLATE_EXPORT SpatialObject : public DataObject using TransformPointer = typename TransformType::Pointer; using TransformConstPointer = const TransformType *; - using VectorContainerType = VectorContainer; + using VectorContainerType = VectorContainer; using BoundingBoxType = BoundingBox; using BoundingBoxPointer = typename BoundingBoxType::Pointer; diff --git a/Modules/Core/SpatialObjects/include/itkSurfaceSpatialObject.h b/Modules/Core/SpatialObjects/include/itkSurfaceSpatialObject.h index aed0e55e249..b98015ca848 100644 --- a/Modules/Core/SpatialObjects/include/itkSurfaceSpatialObject.h +++ b/Modules/Core/SpatialObjects/include/itkSurfaceSpatialObject.h @@ -58,7 +58,7 @@ class ITK_TEMPLATE_EXPORT SurfaceSpatialObject using typename Superclass::BoundingBoxType; using typename Superclass::CovariantVectorType; - using PointContainerType = VectorContainer; + using PointContainerType = VectorContainer; using PointContainerPointer = SmartPointer; /** Method for creation through the object factory. */ diff --git a/Modules/Core/SpatialObjects/include/itkTubeSpatialObject.h b/Modules/Core/SpatialObjects/include/itkTubeSpatialObject.h index b4e12692e1a..fe5a1af6c6b 100644 --- a/Modules/Core/SpatialObjects/include/itkTubeSpatialObject.h +++ b/Modules/Core/SpatialObjects/include/itkTubeSpatialObject.h @@ -57,7 +57,7 @@ class ITK_TEMPLATE_EXPORT TubeSpatialObject : public PointBasedSpatialObject; + using PointContainerType = VectorContainer; using PointContainerPointer = SmartPointer; using typename Superclass::VectorType; using typename Superclass::CovariantVectorType; diff --git a/Modules/Core/Transform/include/itkKernelTransform.h b/Modules/Core/Transform/include/itkKernelTransform.h index 239372536fb..e1edc39834a 100644 --- a/Modules/Core/Transform/include/itkKernelTransform.h +++ b/Modules/Core/Transform/include/itkKernelTransform.h @@ -125,7 +125,7 @@ class ITK_TEMPLATE_EXPORT KernelTransform : public Transform; + using VectorSetType = itk::VectorContainer; using VectorSetPointer = typename VectorSetType::Pointer; /** Get/Set the source landmarks list, which we will denote \f$ p \f$. */ diff --git a/Modules/Filtering/FastMarching/include/itkFastMarchingExtensionImageFilterBase.h b/Modules/Filtering/FastMarching/include/itkFastMarchingExtensionImageFilterBase.h index 187bb5907ce..4615ddf027b 100644 --- a/Modules/Filtering/FastMarching/include/itkFastMarchingExtensionImageFilterBase.h +++ b/Modules/Filtering/FastMarching/include/itkFastMarchingExtensionImageFilterBase.h @@ -82,7 +82,7 @@ class ITK_TEMPLATE_EXPORT FastMarchingExtensionImageFilterBase : public FastMarc /** AuxVarType type alias support */ using AuxValueType = TAuxValue; using AuxValueVectorType = Vector; - using AuxValueContainerType = VectorContainer; + using AuxValueContainerType = VectorContainer; using AuxValueContainerPointer = typename AuxValueContainerType::Pointer; using AuxValueContainerConstIterator = typename AuxValueContainerType::ConstIterator; diff --git a/Modules/Filtering/FastMarching/include/itkFastMarchingTraits.h b/Modules/Filtering/FastMarching/include/itkFastMarchingTraits.h index 812f7244a63..a0f61df8876 100644 --- a/Modules/Filtering/FastMarching/include/itkFastMarchingTraits.h +++ b/Modules/Filtering/FastMarching/include/itkFastMarchingTraits.h @@ -60,7 +60,7 @@ class FastMarchingTraitsBase using OutputPixelType = typename OutputDomainType::PixelType; using NodePairType = NodePair; - using NodePairContainerType = VectorContainer; + using NodePairContainerType = VectorContainer; using NodePairContainerPointer = typename NodePairContainerType::Pointer; using NodePairContainerIterator = typename NodePairContainerType::Iterator; using NodePairContainerConstIterator = typename NodePairContainerType::ConstIterator; diff --git a/Modules/Filtering/ImageSources/include/itkGridImageSource.h b/Modules/Filtering/ImageSources/include/itkGridImageSource.h index 3b86e455dc0..56ee1bbfcd6 100644 --- a/Modules/Filtering/ImageSources/include/itkGridImageSource.h +++ b/Modules/Filtering/ImageSources/include/itkGridImageSource.h @@ -91,7 +91,7 @@ class ITK_TEMPLATE_EXPORT GridImageSource : public GenerateImageSource; using BoolArrayType = FixedArray; using PixelArrayType = vnl_vector; - using PixelArrayContainerType = VectorContainer; + using PixelArrayContainerType = VectorContainer; /** Set/Get kernel function used to create the grid. */ itkSetObjectMacro(KernelFunction, KernelFunctionType); diff --git a/Modules/IO/MeshVTK/include/itkVTKPolyDataMeshIO.h b/Modules/IO/MeshVTK/include/itkVTKPolyDataMeshIO.h index a4586e2a5b7..b00b614cfbd 100644 --- a/Modules/IO/MeshVTK/include/itkVTKPolyDataMeshIO.h +++ b/Modules/IO/MeshVTK/include/itkVTKPolyDataMeshIO.h @@ -56,7 +56,7 @@ class ITKIOMeshVTK_EXPORT VTKPolyDataMeshIO : public MeshIOBase using StringVectorType = std::vector; using StringStreamType = std::stringstream; using PointIdVector = std::vector; - using PolylinesContainerType = VectorContainer; + using PolylinesContainerType = VectorContainer; using PolylinesContainerPointer = PolylinesContainerType::Pointer; /** Method for creation through the object factory. */ diff --git a/Modules/Registration/Common/include/itkPointsLocator.h b/Modules/Registration/Common/include/itkPointsLocator.h index f8bcdd0c6a8..21bddb0bb5e 100644 --- a/Modules/Registration/Common/include/itkPointsLocator.h +++ b/Modules/Registration/Common/include/itkPointsLocator.h @@ -38,7 +38,7 @@ namespace itk * * \ingroup ITKRegistrationCommon */ -template >> +template >> class ITK_TEMPLATE_EXPORT PointsLocator : public Object { public: diff --git a/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest3.cxx b/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest3.cxx index 6314c5c27e3..98fe73d0322 100644 --- a/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest3.cxx +++ b/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest3.cxx @@ -33,8 +33,7 @@ itkEuclideanDistancePointSetMetricTest3Run(double distanceThreshold) { using PointSetType = itk::PointSet; using PointType = typename PointSetType::PointType; - using IdentifierType = itk::IdentifierType; - using PointsContainerType = itk::VectorContainer; + using PointsContainerType = itk::VectorContainer; using PointsLocatorType = itk::PointsLocator; auto pointsLocator = PointsLocatorType::New();