CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: type checking

Hybrid View

  1. #1
    Join Date
    Sep 2003
    Posts
    43

    type checking

    if i got an iterator
    how can i sure that it is a random access iterator??

    will it be a way for testing it??
    thank for reply

    regard
    SAto

  2. #2
    Join Date
    Oct 2002
    Location
    Singapore
    Posts
    3,128
    If I am not wrong, only iterators from std::vector and std::string are random access iterator.

  3. #3
    Join Date
    Apr 1999
    Location
    Altrincham, England
    Posts
    4,470
    You might write your own container with random-access iterators...

    There is std::iterator_traits that can tell you the category of an iterator. This requires some extreme template programming, of course.
    Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
    --
    Sutter and Alexandrescu, C++ Coding Standards

    Programs must be written for people to read, and only incidentally for machines to execute.

    --
    Harold Abelson and Gerald Jay Sussman

    The cheapest, fastest and most reliable components of a computer system are those that aren't there.
    -- Gordon Bell


  4. #4
    Join Date
    Apr 1999
    Location
    Altrincham, England
    Posts
    4,470
    Oh, and std:eque is, I believe, random access.
    Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
    --
    Sutter and Alexandrescu, C++ Coding Standards

    Programs must be written for people to read, and only incidentally for machines to execute.

    --
    Harold Abelson and Gerald Jay Sussman

    The cheapest, fastest and most reliable components of a computer system are those that aren't there.
    -- Gordon Bell


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