There are only 2 use cases known to me for empty angle brackets <> in c++ templates, which are encountered:
1) During template full specialization e.g.
template<typename T>
class X
{};
template<>
class X<char>
{};
2) During the templated function call which argument type's can be deduced e.g.
template<typename T>
T add(T a, T b);
...
add<>(1, 2);
But this case is completely new to me, and I can't understand the meaning of such syntax (please have a look at rapidxml::xml_node<>*):
class TestWidget : public GUI::Widget
{
public:
TestWidget(const std::string& name, rapidxml::xml_node<>* elem);
// ...
};
What semantics are given to the xml_node<> type here in the constructor parameter ???
Not this case (default template argument, as in the Jarod42's answer) but that syntax can also declare an object of a variadic template type with empty list of template arguments.
Or both.
#include <iostream>
// default value
template <typename = void>
struct foo
{ };
// variadic list
template <int ...>
struct bar
{ };
// both
template <int = 0, typename ...>
struct foobar
{ };
int main ()
{
foo<> f;
bar<> b;
foobar<> fb;
}
The funny part it that you can't distinguish the cases from variable declarations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With