Re: with -std=c++0x typeof is gone

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 28 January 2010 01:31, Patrick Horgan <phorgan1@xxxxxxxxx> 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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux