What does this typedef mean

What does the type define mean?

1
2
3
4
5
6
namespace sensor_msgs
{
template <class ContainerAllocator>
...
...
typedef std::vector< ::sensor_msgs::PointField_<ContainerAllocator> , typename ContainerAllocator::template rebind< ::sensor_msgs::PointField_<ContainerAllocator> >::other >  _fields_type;



Last edited on
Try removing all the namespaces and turning it into a ‘using’ statement:
1
2
3
using _fields_type = std::vector< ::sensor_msgs::PointField_<ContainerAllocator> ,
                                  typename ContainerAllocator::template
                                  rebind< ::sensor_msgs::PointField_<ContainerAllocator> >::other > ;


std::vector constructor requires two arguments:
- typename T
- typename Allocator
(but Allocator is defaulted to std::Allocator<T>).

PointField_ is a struct template defined here:
http://docs.ros.org/diamondback/api/sensor_msgs/html/structsensor__msgs_1_1PointField__.html

At first glance, it seems the purpose of this typedef is to let you declare something like:
std::vector<PointField_<T>, "proper allocator for PointField_<T>"> myfields;
just by the simpler sintax:
_fields_type<T> myfields;

I hope I addressed you into the right direction, but I must admit I'm not sure about my hypothesys :-(

Topic archived. No new replies allowed.