[Development] Changing qreal to a float
illissius at gmail.com
Thu Feb 16 15:46:43 CET 2012
On Thu, Feb 16, 2012 at 2:03 PM, <lars.knoll at nokia.com> wrote:
> On 2/16/12 12:16 PM, "ext Giuseppe D'Angelo" <dangelog at gmail.com> wrote:
>>On 15 February 2012 22:56, Sean Harmer <sh at theharmers.co.uk> wrote:
>>> Why not make these classes into templates and have typedefs for the
>>> float and double cases? It always confused me why QVector<n>D mixed
>>> qreals and floats.
>>I agree, although typedefs will unfortunately break all forward
> That would break quite a bit of code, so I'm against it.
> It's not a big deal to simply add the QRectD, etc. types if required.
You could use inheritance:
struct QRectD: public QRectT<double>
For the forwarding constructors you could either write them out
manually, which is a chore (but considerably less than doing it for
the whole class), or write template constructors for each arity at the
price of worse error messages. Possibly you could automate the whole
thing with a macro. The problem you can run into is that QList<
QRectT<double> > and QList<QRectD> would no longer be compatible, I'm
not sure if there are others.
More information about the Development