Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

so, this is more a C than a c++ construct:

typedef Ptr<Layer>(*Constructor)(LayerParams &params);

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

so, this is more a C than a c++ construct:

typedef Ptr<Layer>(*Constructor)(LayerParams &params);

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);