Opened 15 years ago

Closed 15 years ago

#334 closed enhancement (fixed)

return Derived* from make_classifier not SupervisedClassifier

Reported by: Peter Owned by: Markus Ringnér
Priority: trivial Milestone: yat 0.4
Component: classifier Version: trunk
Keywords: Cc:


needs ticket:318

The SupervisedClassifier? interface requires inherited classes to have a function make_classifier returning a SupervisedClassifier?*. Some classes does this and some returns Derived*. What is the difference?

Well, Derived* can be converted to SupervisedClassifer?* but the other way around is not true. Say that you have a template with a Classifier e.g. EnsembleBuilder?. You wanna make a copy of your classifier prototype and typically you can do that using copy constructor

T* sc2 = new T(*sc);

However this will not work if T is SupervisedClassifer?. In that case you would need to use the make_classifier function, which works as a dynamic copy constructor. You change the code to

T* sc2 = sc->make_classifier();

This will work as long as make_classifer returns T*. If suddenly T is NCC and NCC::make_classifer returns SupervisedClassifer?*, it will not compile. Therefore make_classifer should return Derived*.

Change History (2)

comment:1 Changed 15 years ago by Markus Ringnér

Milestone: yat 0.x+yat 0.4

comment:2 Changed 15 years ago by Markus Ringnér

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.