Re: [eigen] comma initializers, perfect forwarding and variadic templates |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
dear Eigen devs, first of all, thank you for this great library !now, I have a feature request ( unless I missed an already existing way to do it, of course ).I need to comma initialize some Eigen matrices by perfect-forwarding a parameter pack in a variadic template; clearly, this will be easily possible with c++17 fold expressions, but ,as of now, we have no ready made solution ( as far as I can tell ).Yet, this can be easily implemented in c++11<= compilers < c++17, something equivalent totemplate < typename H >auto&& CommaUnPack( H&& head ){ return std::forward<H>(head); }
template < typename H, typename S, typename... T >auto&& CommaUnPack( H&& head, S&& secnd, T&&... args ){return CommaUnPack( std::forward<H>(head).operator,( std::forward<S>(secnd) ), std::forward<T>(args)... );}to be used asCommaUnPack( SomeEigenExpr << std::forward<decltype(head)>(head), std::forward<decltype(tail)>(tail)... ); // or anything equivalent, like the possibly more consistent ( SomeEigenExpr << std::forward<decltype(head)>(head) ).finished_unpack( std::forward< decltype(tail)>(tail)... )// or ...note that, given the existing comma initializer implementation, this should never create dangling references and hence be relatively safe to use.I know we can do it via library solutions offered by boost & others, but still, I think this would be a useful addition to Eigen initialization tools. What do you think ?thank you, MJ
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |