Question regarding template and union tags

Hi!

This is more a C++ general question rather than UAVCAN related. Coming from C language I am a bit new to some C++ features such as templates. However, I am trying to make a function template that needs a union tag to create a uavcan request as below. T and V typenames works, but how can I make the tag a template as well?

template <typename TAG, typename T, typename V>
myFunction(uavcan_linux::NodePtr& node, [TAG], V& value) {
...
		typename T::Request request;
		request.to<[TAG]>() = value;  // Does not work... 
...
}

Kind regards

It doesn’t work because in a template context the compiler can’t know the kind of to; it doesn’t expect a template instantiation construct ahead. You have to tell the compiler that a template is coming by saying request.template to<TAG>().

In the future, when something isn’t working, please post what exactly the problem is and what error messages you’re seeing, otherwise it might be difficult to understand what’s happening.

Yes, will do!
Thanks for the response, I understand your comment and will redo my work.

Thanks!
Regards