1 | initial version |
so, this is more a C than a c++ construct:
typedef Ptr<Layer>(*Constructor)(LayerParams ¶ms);
is the definition of a function pointer, called Constructor
, which takes LayerParams
as arguments and returns a Ptr<Layer>
, you can pass it as an argument to other functions, like
void factory(Constructor c, LayerParams lp) {
Ptr<Layer> lyr = c(lp); // make a layer
// use the layer for something, e.g. constructing a graph
}
and later:
factory(dnn::SliceLayer::create, params); // SliceLayer::create() fits the "Constructor" signature
2 | No.2 Revision |
so, this is more a C than a c++ construct:
typedef Ptr<Layer>(*Constructor)(LayerParams ¶ms);
is the definition of a function pointer, called Constructor
, which takes LayerParams
as arguments and returns a Ptr<Layer>
, you can pass it as an argument to other functions, like
void factory(Constructor c, LayerParams lp) {
Ptr<Layer> lyr = c(lp); // make a layer
// use the layer for something, e.g. constructing a graph
}
and later:
factory(dnn::SliceLayer::create, params); // SliceLayer::create() fits the "Constructor" signature
factory(dnn::SliceLayer::create, params);