I have class which accepts one int
template parameter, and one int
parameter pack (neurons
). One of the constructor's goals is to take each of the parameters in the pack and add an instance of a class to a vector. The class, however, takes its arguments as template parameters.
I have the following code:
template<int iCount, int... neurons>
class network {
private:
std::vector<pl> layers;
public:
network() : layers() {
input_layer<iCount> inp;
layers.push_back(inp);
addLayer<iCount, neurons...>();
}
template<int prev, int nc, int... further>
void addLayer() {
layer<nc, prev> l;
layers.push_back(l);
addLayer<nc, further...>(); // error is here
}
};
The recursive call, which is labeled with 'error is here', produces a compiler error: "Error 4 error C2783: 'void network<1,3,2,1>::addLayer(void)' : could not deduce template argument for 'nc'"
pl
is the parent class of both input_layer
and layer
.
At the moment, I using network
like so:
network<1, 3,2,1> n;
After invoking the constructor, I would expect that n.layers would contain four elements. The first being an input_layer
, to which iCount
was passed, and the remained being layer
s with the corresponding entry in neurons
as its nc
, and the previous layer's nc
as its prev
.