Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2004-08-31 09:19:22

"Peder Holt" <peder.holt_at_[hidden]> wrote

> To be precise, m*N/2
> To deduce the type of an expression
> int* a[10],
> sizeof(foo<n>(a)), n=1..N
> the compiler needs to generate the following types (names may vary)
> encode_array<T[10],1>
> encode_array<T[10],2>
> encode_pointer<T*,1>
> encode_array<T[10],3>
> encode_pointer<T*,2>
> encode_impl<int,1>
> encode_array<T[10],4>
> encode_pointer<T*,3>
> encode_impl<int,2>
> encode_dummy
> ...
> -> N.
> that is, N*m/2 types needs to be generated by the compiler. Please
> correct me if I'm wrong.

In my implementation there is no encode_array<T[10], 1>,
encode_array<T[10],2>, etc.

There is:

template<class V, class T, int Size> struct encode_type_impl<V, const

Which is the same type throughout BOOST_TYPEOF invocation, and therefore
gets instantiated only once. So I insist that the order of my algorithm is
O(N), which results from the need to instantiate "foo<n>(expr)" for every n
from 0 to N-1.

If you came up with an O(M) rather than O(N) algorithm, where M is the real
size of the encoding sequence, this is really great for simple types. I'll
do my best to understand your solution and adapt it to my implementation (if
possible). For now, it really looks more like a miracle to me...

> I think i am closing in on the ultimate typeof implementation.

The "ultimate" implementation will come from the compiler vendors :)


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