[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [eigen] Inheritence
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Fri, 5 Feb 2010 09:27:53 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=sEAGAwdVcLBDRa5WSeJfsfLNDs8FAt5gsX+fnHKvRew=; b=jFaxoiEPFLhXany0uCN1r2MDcze2xPNeUV+jKTFJpU59kSL9+CgL9zx7iUWwXQ44Rq 6hpQTNBlq3vsvLWOc1dnnrFYJjTFemQXlGajBG1KMKt+nwBQso336RwGSbZ8qFPcM7IZ Di1Xqqb4+Bsh2Td20AhRKbTB53W5GEl+px9d0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=G9M+C3HEEguVtDsTmq+Qcf5ARH4j8/vpeG52GwhEvMM6ViEcmxWHy6ZOfn1lbW2JyE J2W91Q/H8xVsY9GRlpXcmT5j2OpLOHd6n5/b9ceSHJLosPEo0OmUCMXoJqABkrdNBO85 jo0awv9fhJwiwbIW0qpnGLlKtu9zxi0lkHmY8=
note that in the devel branch you can do something much better: inherit DenseMatrixBase instead of Matrix. This way YourType inherit MatrixBase<YourType> and not MatrixBase<Matrix> that is much better and safer. For instance if you need different traits than Matrix. Also calling .derived() on a MatrixBase<Derrived> will return a YourType instead of a Matrix object, etc.
On Fri, Feb 5, 2010 at 9:02 AM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
You would for example have to if some function taking a T& tried to
use ei_traits<T>::Flags, and then you pass an object of your derived
class to that function.
However, I can't think of a valid case for a function to do that.
Instead of using ei_traits<T>::Flags, it should use T::Flags. So if
you remember what triggered a compilation error when not specializing
ei_traits, please tell me.
ei_traits is only there as a forward-declaration trick for CRTP
classes. It is only an internal device.
2010/2/5 Thomas Capricelli <orzel@xxxxxxxxxxxxxxx>:
> Well actually, i remember that in some cases i needed to define the ei_traits (i have it in a #if 0/#endif in my code), but i couldn't say which case :/..... just that right now, i dont need for my use case
> Thomas Capricelli <orzel@xxxxxxxxxxxxxxx
> In data venerdì 05 febbraio 2010 08:02:52, Benoit Jacob ha scritto:
>> MyMatrix inherit Matrix which inherits MatrixBase<Matrix>.
>> So whenever an object of class MyMatrix is seen as a MatrixBase, it is
>> a MatrixBase<Matrix> so it uses ei_traits<Matrix>.
>> So, forget my recommendation about ei_traits.