Opened 13 years ago

Closed 13 years ago

#322 closed enhancement (fixed)

Classes templatized on Distance should take Distance in constructor

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

Description

This is better to be done after ticket:318

As now a Distance instance is initialized using default constructor. We should allow user to pass a Distance in constructor in order to allow for Distances for which default constructor is not enough (e.g. if the Distance is not an empty Functor but holds some parameter).

I think we should keep the support for constructor without Distance since that is most common case and just anoying to have to pass an instance when you already told in template argument what you wanna use.

Change History (2)

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

I guess we could keep a single constructor and get all the functionality with a default constructor for Distance as the default parameter for the distance argument

template <typename Distance>
class Aclass 
{
  Aclass(...., const Distance& dist = Distance()); 
};

However, there may be considerations which should tell us two use two constructors:

http://www.codesynthesis.com/~boris/blog/2006/12/06/default-argument-or-overloading/

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

Resolution: fixed
Status: newclosed

Fixed in [1158] (ticket:318 was fixed enough for this in [1157])

Note: See TracTickets for help on using tickets.