Subject: Re: [boost] different matrix library?
From: DE (satan66613_at_[hidden])
Date: 2009-08-17 12:13:17
on 17.08.2009 at 17:54
joel wrote :
> First, concrete inheritance like this == bad performances. Use CRTP
> I'm against the proliferation of such types cause it'll just pollute and
> the namespace when a simple policy things is easy to do and have same
> set of features.
first, it does use crtp
i omitted template parameters for simplicity
there is no performance degradation
> And anyway, your exampel is faulty, you should ask your user to wait for
> any type T that is a matrix expression with symmetric features
> or when you'll call f( a+b*c ); you'll get spurious copy.
> so the actual generic way to write this should be :
> template<class T>
> typename enable_if_c< as_matrix<T>::value
> && is_same< settings<T,shape>,symmetric>>::value
> f( T const& m );
> but we can't have user write that so a small macro thingy will be needed.
actually since symmetric_matrix uses crtp the user gets just what he
if you supply an actual object it will be passed by reference
otherwise the result of an expression will be copied to a temporary
and that temorary will be passed by reference (probably that's just
what the user needs)
finally if the user is advanced, he may write
void foo(const symmetric_matrix_expression<expression_type> &m);
perfectly readable, typesafe, excellent performance, easy to
understand and implement
> You should read and learn about : SFINAE ,boost::enable_if and
> That's ages that cryptic error messages int empalte are no more.
just this moment there is a discussion about enable_if issues
you might be interested
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk