Boost logo

Boost :

From: Jaakko Jarvi (jajarvi_at_[hidden])
Date: 2002-02-19 10:07:52

Getting back to typeof from auto.

Previous postings claim that typeof doesn't help much, as the
return type expressions would be complicated and hard to write/read in any

Here's a suggestion for a feature of typeof that could be of help in this

Extend the scope of the function parameters to the return type expression,
and allow them to be used inside a typeof (and sizeof) expression there.

For example:

template<class A, class B>
vector<typeof(a[0]+b[0])> sum(const vector<A>& a, const vector<B>& b);

Forward declaration is possible,
and it'd be quite a lot easier than to write something like:

vector<typeof((*(const vector<A>*)0)[0] + (*(const vector<B>*)0)[0])>

(cast 0 to const vector<A>*, dereference it and take the first element,
same for vector<B>, do the addition and take typeof)

I cannot see any major difficulties in incorporating this feature to


Boost list run by bdawes at, gregod at, cpdaniel at, john at