meaning of this template struct

How to describe this template structure in words
what is the use of ContainerAllocator? I find it being used in the code as,
typedef ::geometry_msgs::Quaternion_<ContainerAllocator> _orientation_type;
why is _alloc used?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
template <class ContainerAllocator>
struct Header_
{
  typedef Header_<ContainerAllocator> Type;

  Header_()
    : seq(0)
    , stamp()
    , frame_id()  {
    }
  Header_(const ContainerAllocator& _alloc)
    : seq(0)
    , stamp()
    , frame_id(_alloc)  {
  (void)_alloc;
    }
Last edited on
typedef ::geometry_msgs::Quaternion_<ContainerAllocator> _orientation_type; doesn't define what ContainerAllocator is. It's using it to define a type dependent on it.

Presumably ContainerAllocator is an allocator.
https://en.wikipedia.org/wiki/Allocator_(C%2B%2B)

Line 15 is somewhat mystifying to me. This is usually done when a function doesn't use a parameter, so the compiler doesn't give warnings about unused parameters, but the constructor does use _alloc.

By the way, identifiers that begin with underscores are supposed to not be used, because the implementation reserves them for its own purposes. IMO, identifiers that begin or end with underscores are kinda shitty.
Topic archived. No new replies allowed.