Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 735333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:28:38+00:00 2026-05-14T07:28:38+00:00

In code: //I know that to get this effect (being able to use it

  • 0

In code:

//I know that to get this effect (being able to use it with std algorithms) I can inherit like I did in line below:

    class Iterator //: public std::iterator<std::bidirectional_iterator_tag,T>

    {
    private:
        T** itData_;
    public:
        //BUT I WOULD LIKE TO BE ABLE TO DO IT BY HAND AS WELL
        typedef std::bidirectional_iterator_tag iterator_category;
        typedef T* value_type;//SHOULD IT BE T AS value_type or T*?
        typedef std::ptrdiff_t difference_type;
        typedef T** pointer;//SHOULD IT BE T* AS pointer or T**?
        typedef T*& reference;//SHOULD IT BE T& AS reference or T*&?
};

Basically what I’m asking is if I have my variable of type T** in iterator class is it right assumption that value type for this iterator will be T* and so on as I described in comments in code, right next to relevant lines.
Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:28:38+00:00Added an answer on May 14, 2026 at 7:28 am

    The definition in the standard (section 24.3.2) is:

    template<class Category, class T, class Distance = ptrdiff_t,
             class Pointer = T*, class Reference = T&>
    struct iterator {
        typedef T value_type;
        typedef Distance difference_type;
        typedef Pointer pointer;
        typedef Reference reference;
        typedef Category iterator_category;
    };
    

    As you can see, the defaults are:

    typedef T value_type;
    typedef ptrdiff_t difference_type;
    typedef T* pointer;
    typedef T& reference;
    

    This is assuming that the iteration is over a container of elements of type T. If your container holds elements of type T* instead, the typedefs in your question would be correct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any real use for self modifying code ? I know that they
Does anyone know of any code or tools that can strip literal values out
Does anyone know a good website that summarises what you can do with code
You know that particular part of your code that is essential for the project
I know that IntelliJ has an option to select all the code in a
I know that using continuous integration improves the quality of my code base, and
I know that there is no way to fully protect our code. I also
We all know that commenting our code is an important part of coding style
I am working on some code coverage for my applications. Now, I know that
Does anyone know of existing code that lets you draw fully justified text in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.