1

I stumbled across the following:

template<> inline bool Value::GetValue<bool>() const {
    return m_Value.ValueBoolean();   // union
}

Can’t understand what the empty template declaration does ?

Kjell Gunnar
  • 3,017
  • 18
  • 24

2 Answers2

3

This is an explicit specialization of a template function for type bool. Explicit specialization is where template <> syntax is used.

template <typename T> void foo(T t) // Main template
{ 
  ... 
} 

template <> void foo<bool>(bool b) // Explicit specialization for type `bool`
{ 
  ... 
} 

The fact that in your example it is applied to a template of a class member function is completely inconsequential. The fact that the function is declared inline is also completely besides the point.

AnT stands with Russia
  • 312,472
  • 42
  • 525
  • 765
1

It is an explicit specialization.

robert
  • 3,539
  • 3
  • 35
  • 56