what does template <> mean?

I come across the following code, and I'm at a loss what they are


1
2
3
4
5
6
7
8
9
10
	template <>
	struct default_converter<luabindx::lightuserdata_t>
	  : native_converter_base<luabindx::lightuserdata_t>
	{
		void func1(){}

                void func2(){}
            
	};


I want to know
1) how to understand template <>? I know template <T>, but why there is no T here?

2) what does struct default_converter<luabindx::lightuserdata_t>: native_converter_base<luabindx::lightuserdata_t> mean? it looks to be a struct, but why there is a ":"?
1) template <> is simply a template that does not take any arguments. Not sure why it is even a template.

2) Yes, it is a struct declarations. It is declaring a struct type called default_converter qualified by luabindx::lightuserdata_t. The : indicates it inherits from another struct, native_converter_base<luabindx::lightuserdata_t>
template <> is simply a template that does not take any arguments

Isn't is rather an explicit specialization for luabindx::lightuserdata_t?
https://msdn.microsoft.com/en-us/library/c401y1kb.aspx
That's an explicit specialization of the class template default_converter<T> with T=luabindx::lightuserdata_t

another link about explicit specializations, http://en.cppreference.com/w/cpp/language/template_specialization
Last edited on
Topic archived. No new replies allowed.