Reputation: 153
I have been having a look into the vulkan-hpp source code to try to understand how to manage StructureChain
s. I've found this odd looking syntax (line marked with comment) related with the usage of template
keyword as a member type. Moreover, its followed by a function call with no ;
preceding.
template<typename X, typename Y, typename ...Z, typename Dispatch>
VULKAN_HPP_INLINE StructureChain<X, Y, Z...> PhysicalDevice::getFormatProperties2( VULKAN_HPP_NAMESPACE::Format format, Dispatch const &d ) const VULKAN_HPP_NOEXCEPT
{
StructureChain<X, Y, Z...> structureChain;
VULKAN_HPP_NAMESPACE::FormatProperties2& formatProperties = structureChain.template get<VULKAN_HPP_NAMESPACE::FormatProperties2>(); //This line
d.vkGetPhysicalDeviceFormatProperties2( m_physicalDevice, static_cast<VkFormat>( format ), reinterpret_cast<VkFormatProperties2*>( &formatProperties ) );
return structureChain;
}
Can anyone help me to figure out the meaning of this line?
Upvotes: 1
Views: 278
Reputation: 10606
This template
keyword is used to disambiguate the following expression as a template instantiation.
structureChain
type depends on template parameters, so the compiler cannot know how to interpret the following get<VULKAN_HPP_NAMESPACE::FormatProperties2
expression, which may be an instantiation of a get
template, or comparison expression. The template
keyword indicates that get
is a template, and the following is a template instantiation. In the absence of this keyword the compiler would assume get
is not a template, so the following must be a comparison expression.
See here.
Upvotes: 5