$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] [typeof] 2 questions
From: Daniel Walker (daniel.j.walker_at_[hidden])
Date: 2010-05-19 13:47:26
On Tue, May 18, 2010 at 9:03 PM, Eric Niebler <eric_at_[hidden]> wrote:
> Rearranging because I top-posted. :-P
>
> On 5/17/2010 6:12 PM, Daniel Walker wrote:
>> On Sun, May 16, 2010 at 3:23 PM, Eric Niebler <eric_at_[hidden]> wrote:
>>> On 5/11/2010 7:48 AM, Eric Niebler wrote:
>>>> 2) I can't find "decltype" by grepping the typeof code. Why doesn't
>>>> typeof use the decltype keyword on compilers that support it?
>>
>> I think there are some differences. As I recall, typeof doesn't
>> preserve references whereas decltype does, so existing code could be
>> broken in some situations. But I second you're suggestion of migrating
>> to decltype where available/possible.
>
> I think it would be a simple matter to strip top-level references. Consider:
>
> template<typename T> T unref(T const &);
> #define BOOST_TYPEOF(x) decltype(unref(x))
>
> That way the semantics of existing code remains unchanged.
>
Yeah, that could do the trick. The regression tests may turn up other
differences, which could be addressed as they're discovered, but this
looks doable. It would be a boon to users, since they'd no longer have
to register their types. And it would reduce compile time overhead.
Daniel Walker