On 10/10/12, Xinliang David Li <davi...@google.com> wrote:
> In a different thread, I proposed the following alternative to 'try_xxx':
>
> template<typename T> T* symbol::cast_to(symbol* p) {
>    if (p->is<T>())
>       return static_cast<T*>(p);
>    return 0;
>  }
>
> cast:
>
> template<typename T> T& symbol:as(symbol* p) {
>    assert(p->is<T>())
>    return static_cast<T&>(*p);
>
>  }

My concern here was never the technical feasibility, nor the
desirability of having the facility for generic code, but the amount
of the amount of typing in non-generic contexts.  That is

  if (cgraph_node *q = p->try_function ())

versus

  if (cgraph_node *q = p->cast_to <cgraph_node *> ())

I thought the latter would generate objections.  Does anyone object
to the extra typing?

If not, I can make that change.

-- 
Lawrence Crowl

Reply via email to