|
2007/2/25, Thomas Harning Jr. <harningt@gmail.com>:
On 2/25/07, Matthew A. Nicholson <matt@matt-land.com> wrote: Great job on the library, however I think it could use a little fixing for the 'as' function. Passing in a variable of the type in order to get C++ to know what type to use doesn't sound like the best idea. Using C++ templates seems to make the most sense to me. Instead of: int val = L.as(0, index); It would be: int val = L.as<int>(index); ... Just my 2 cents.
I was about to make the same suggestion. And if your original intention was to write more generic code like : int val; val = L.as(val, index); with a modern compiler you could write : int val = L.as<typeof(val)>(index); Not all compiler support the typeof operator yet, but GCC does and template based limited implementations exist for those that don't.