--
Is there any reason why we can't add:int[20] foo;
unknown[5] = 10;
It is more consistent, easier to understand, easier in complicated cases like the return from a function, etc.
Am 04.12.2012 10:40 schrieb "Tony V E" <tvan...@gmail.com>:
>
> Sorry, right. But you can do reference to an array. I was thinking of some of those ugly cases in the various countof templates.
>
This is taken care of with alias templates
template<typename T> using id = T;
So you can say
id<char const [3]> &x = "12";
>
> Sent from my portable Analytical Engine
>
Sent from my portable android device.
> ________________________________
> From: "Nevin Liber" <ne...@eviloverlord.com>
> To: "std-dis...@isocpp.org" <std-dis...@isocpp.org>
> Sent: 4 December, 2012 3:40 AM
>
> Subject: Re: [std-discussion] typedef an array
>
> On 4 December 2012 01:49, Tony V E <tvan...@gmail.com> wrote:
>>
>> It is more consistent, easier to understand, easier in complicated cases like the return from a function, etc.
>
>
> Um, you can't return an array from a function..
> --
> Nevin ":-)" Liber <mailto:ne...@eviloverlord.com> (847) 691-1404
>
> --
>
>
>
>
> --
>
>
>
Am 04.12.2012 10:40 schrieb "Tony V E" <tvan...@gmail.com>:
>
> Sorry, right. But you can do reference to an array. I was thinking of some of those ugly cases in the various countof templates.
>
This is taken care of with alias templates
template<typename T> using id = T;
So you can say
id<char const [3]> &x = "12";
>
> Sent from my portable Analytical Engine
>
Sent from my portable android device.
> ________________________________
> From: "Nevin Liber" <ne...@eviloverlord.com>
> To: "std-dis...@isocpp.org" <std-dis...@isocpp.org>
> Sent: 4 December, 2012 3:40 AM
>
> Subject: Re: [std-discussion] typedef an array
>
> On 4 December 2012 01:49, Tony V E <tvan...@gmail.com> wrote:
>>
>> It is more consistent, easier to understand, easier in complicated cases like the return from a function, etc.
>
>
> Um, you can't return an array from a function..
> --
> Nevin ":-)" Liber <mailto:ne...@eviloverlord.com> (847) 691-1404
>
> --
>
>
>
>
> --
>
>
>
Maybe I was being to curt and cryptic. The original question was about typedef, I kind of went off on a tangent. Basically, I find many new users get hung up on declaring arrays. They expect this to work:int[20] foo;
And stumble over:int foo[20];
I think you could also extend the argument to other unwieldy C/C++ declarations, like pointers to functions, etc.