-
February 5th, 2009, 09:40 AM
#16
Re: pointer issues
Originally Posted by PredicateNormative
Something like this should do it:
Code:
template <typename T, size_t U>
size_t size(T (&arr)[U])
{
return sizeof(arr)/sizeof(arr[0]);
}
That's kind of redundant, don't you think? You already have the size (in the form of U).
See the second snippet in my original post for what I mean.
-
February 5th, 2009, 10:07 AM
#17
-
February 5th, 2009, 10:15 AM
#18
Re: pointer issues
Originally Posted by PredicateNormative
It is redundant - I wasn't on the ball when replying to that one... In addition to the redundant logic and the pointless naming of the array, I also got the case wrong on the U in the code and forgot to mark the parameter as const!
Happens to everyone once in a while.
Originally Posted by PredicateNormative
How did you do the highlighting?
I used the HL BB code tag.
-
February 5th, 2009, 10:45 AM
#19
Re: pointer issues
Thanks
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|