Reputation: 1373
my question may look strange for many of you and I am really sorry for that.
As I can remember, I managed few years ago to define a class with a default template parameter such that the syntax
Foo<> f;
can be replaced by
Foo f;
However, I cannot remember how I did that. I thought Foo class was defined with variadic templates and the default template parameter was an integer value (SIZE) but I don't manage to reproduce the target syntax.
Does anybody know how to do that? If it was just a dream, I'm really sorry!
EDIT: well, as far as I can remember, the base of the trick was to redefine
template<int SIZE=0>
class Foo;
with some variadic templates. But I am aware that my question is strange and that it is probably impossible to obtain such a syntax... :)
Upvotes: 0
Views: 64
Reputation: 41750
A nice solution would be to define an alias to you type.
template<std::size_t size = 0>
struct Foo {
// ...
};
using DefaultFoo = Foo<>;
You can't have the same name though...
Upvotes: 1