This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: with -std=c++0x typeof is gone
- From: me22 <me22 dot ca at gmail dot com>
- To: phorgan1 at yahoo dot com
- Cc: GCC-help <gcc-help at gcc dot gnu dot org>
- Date: Thu, 28 Jan 2010 01:53:31 -0500
- Subject: Re: with -std=c++0x typeof is gone
- References: <4B612F3E.5040409@yahoo.com>
On 28 January 2010 01:31, Patrick Horgan <phorgan1@yahoo.com> wrote:
> In a templated class we define our difference type like this:
>
> Â Â Â typedef typeof(T() - T()) differenceType;
>
That works? Wouldn't it give unsigned when T is unsigned?
> How simple, how elegant, but typeof is not part of the C++ standard, and
> isn't available when we use -std=c++0x. ÂOther than using specializations
> for each type that we might use with this class, is there some other
> equivalently simple way to do this?
>
I assume that decltype can do it.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2115.pdf
~ Scott