CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19

Thread: pointer issues

  1. #16
    Join Date
    Jun 2006
    Location
    M31
    Posts
    885

    Re: pointer issues

    Quote Originally Posted by PredicateNormative View Post
    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.

  2. #17
    Join Date
    May 2007
    Location
    Scotland
    Posts
    1,164

    Re: pointer issues

    Sorry Plasmator I didn't see your post

    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!

    Come to think of it (even if I had written it correctly), my whole post was redundant even before I hit the 'Submit Reply' button.

    How did you do the highlighting?

    Quote Originally Posted by PredicateNormative
    Still the rest of the post counts.
    I take that back.

  3. #18
    Join Date
    Jun 2006
    Location
    M31
    Posts
    885

    Re: pointer issues

    Quote Originally Posted by PredicateNormative View Post
    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.
    Quote Originally Posted by PredicateNormative View Post
    How did you do the highlighting?
    I used the HL BB code tag.

  4. #19
    Join Date
    May 2007
    Location
    Scotland
    Posts
    1,164

    Re: pointer issues

    Thanks

Page 2 of 2 FirstFirst 12

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
  •  





Click Here to Expand Forum to Full Width

Featured