J
John Harrison
I want to write a templated constructor with a non-type template argument,
like this.
class X
{
public:
X() : val(0) {}
template <int I>
X(X const&, X const&) : val(I) {}
private:
int val;
};
This compiles but I have no idea how to 'call' this constructor. Is it
possible?
(Essentially I have a single algorithm to construct an X from two other X's
and I would like to customise that algorithm at compile time using an
integer parameter).
john
like this.
class X
{
public:
X() : val(0) {}
template <int I>
X(X const&, X const&) : val(I) {}
private:
int val;
};
This compiles but I have no idea how to 'call' this constructor. Is it
possible?
(Essentially I have a single algorithm to construct an X from two other X's
and I would like to customise that algorithm at compile time using an
integer parameter).
john