Nasos Iliopoulos <nasos_i <at> hotmail.com> writes:
>take a look at Jesse's implementation for "tie" in trac:
Hopefully people don't take my implementation for vector tie's too seriously.  It 'works' but I am not sure it is elegant or efficient.
One other question was whether the term 'tie' is a good one.  I like the consistency with boost::fusion and std::tuple tie functions as a generic term for connecting to multiple return types, but I can understand other views that this is a kind of splitting functione.  My main use case is in splitting a vector of unrelated coefficients used in an optimizer, so the idea of  'tie' ing multiple return types into scalars rather than just 'splitting' up a vector makes more sense to me.

>this can be generalized to achieve "referenced return" or sort of. Imagine for example:
>overall, you will be able to do things like:
>S = svd(A);
>tie(Q,W) = svd(A);
>tie(U, S, V) = svd(A);

I didn't think of that ingenious way to overload based on return types and still keep ublas::tie generic.

One thing to consider though is how it might interact with 'auto'.  The problem becomes that decltype(svd(A)) == svd_impl<decltype(A)> whereas people might expect: 
auto S = svd(A);
or
std::cout << svd(A);
... to be a valid matrix or at least work like one.  One solution may be that the svd_impl is itself a matrix expression which calls apply1 if accessed...