Re: [OT] Re: 2 stupid array questions!!
From: Alan Balmer (albalmer_at_att.net)
Date: 10/10/03
- Next message: Jonas: "Re: Does standard C guarantee same memory content after realloc()?"
- Previous message: Ivan Vecerina: "Re: dynamic declaration of struct array"
- In reply to: Ivan Vecerina: "Re: [OT] Re: 2 stupid array questions!!"
- Next in thread: Jack Klein: "Re: [OT] Re: 2 stupid array questions!!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 10 Oct 2003 14:26:41 -0700
On Fri, 10 Oct 2003 23:23:45 +0200, "Ivan Vecerina"
<ivecATmyrealboxDOTcom> wrote:
>> > // returns the size of the C array passed as a param
>> > // This is safer than the sizeof(a)/sizeof(a[0]) trick...
>> > template <typename T, int N> inline
>> > int arraySize(T (&)[N]) { return N; }
>>
>> This can only be used in the scope of the declaration of the array you're
>> going to pass along.
>
>Yes. And it will produce a compile error when mis-used.
>As stated in my comment, this is much safer than the classic sizeof trick.
It *always* produces a compile-time error in C.
*Please* move this thread to a C++ group.
-- Al Balmer Balmer Consulting removebalmerconsultingthis@att.net
- Next message: Jonas: "Re: Does standard C guarantee same memory content after realloc()?"
- Previous message: Ivan Vecerina: "Re: dynamic declaration of struct array"
- In reply to: Ivan Vecerina: "Re: [OT] Re: 2 stupid array questions!!"
- Next in thread: Jack Klein: "Re: [OT] Re: 2 stupid array questions!!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|