J
Juha Nieminen
For a series of classes I'm making it would be nice if they had constructors
that accept:
- an interator range,
- an initializer list, and
- a variable amount of arguments (using a variadic template)
The first two are trivial, but the third one clashes badly with the first
one. The third constructor is not absolutely mandatory, but it would be a
nice-to-have feature. However, I must admit that regardless of my C++
experience, I don't know if it could be even theoretically possible to
have both the first and the third constructors at the same time.
The problem is that the parameter types can be anything (or, more precisely,
this is a templated class whose template type can be anything, and the
variadic constructor would take parameters of that type). The parameters
to the variadic constructor can very well be pointers.
Therefore I don't see any way of distinguishing between the first and the
third constructor: If you give the constructor two pointers, it matches
both constructor overloads.
Any ideas if this could even theoretically be possible?
that accept:
- an interator range,
- an initializer list, and
- a variable amount of arguments (using a variadic template)
The first two are trivial, but the third one clashes badly with the first
one. The third constructor is not absolutely mandatory, but it would be a
nice-to-have feature. However, I must admit that regardless of my C++
experience, I don't know if it could be even theoretically possible to
have both the first and the third constructors at the same time.
The problem is that the parameter types can be anything (or, more precisely,
this is a templated class whose template type can be anything, and the
variadic constructor would take parameters of that type). The parameters
to the variadic constructor can very well be pointers.
Therefore I don't see any way of distinguishing between the first and the
third constructor: If you give the constructor two pointers, it matches
both constructor overloads.
Any ideas if this could even theoretically be possible?