0

I wrote two functions.

PointCloud<PointXYZ>::Ptr rotateCloud(PointCloud<PointXYZ>::Ptr src);
PointCloud<PointXYZRGB>::Ptr rotateCloud(PointCloud<PointXYZRGB>::Ptr src);

In these two functions, I write completely same code without inside <>. <PointXYZ> or <PointXYZRGB>.

I want to write a single function.I heard there is Template.I tried it.

template <typename T>
PointCloud<T>::Ptr rotateCloud(PointCloud<T>::Ptr src);

I got error.

use the 'typename' keyword to treat nontype "pcl::PointCloud<PointT>::Ptr [with PointT=T]" as a type in a dependent contextC/C++(2675)

I can't understand this error message.

Anyone can understand?

opz
  • 3
  • 1
  • This question's shown code fails to meet Stackoverflow's requirements for showing a [mre]. Because of that it's unlikely that anyone here can conclusively answer the question; but only guess at the most. You need to [edit] your question to show a minimal example, no more than one or two pages of code (the "minimal" part), that everyone else can cut/paste ***exactly as shown***, compile, run, and reproduce the described issue (the "reproducible" part, this includes any ancillary information, like any input to the program). See [ask] for more information. – Sam Varshavchik Apr 25 '22 at 12:28

1 Answers1

2

Since ::Ptr is a dependent type you need typename on the argument and return type

template <typename T>
typename PointCloud<T>::Ptr rotateCloud(typename PointCloud<T>::Ptr src);
Cory Kramer
  • 114,268
  • 16
  • 167
  • 218