0
template<class T=int>
void foo() {}

template<class T=int>
struct bar {};

int main() {
    foo<long>();
    foo<>();
    foo();

    bar<long>();
    bar<>();
    //bar(); // compilation failure, 'bar' no appropriate default constructor available
}

I am not understanding why structs and classes (such as bar) require angle brackets if a default specialization is provided. For foo, I am able to call it without the angle brackets, whereas bar requires empty angle brackets.

If I try create bar without angle brackets I get a seemlingly (to me) unrelated error.

Any insight would be helpful.

Edit: Compiled on Visual C++ 2015

Michael Choi
  • 610
  • 5
  • 22

0 Answers0