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 7785777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:18:36+00:00 2026-06-01T20:18:36+00:00

I am attempting to create a vector iterator within a template class I am

  • 0

I am attempting to create a vector iterator within a template class I am creating. The following is the trouble code.

void editor<T>::insert()
{   
        typedef typename std::vector<T>::const_iterator itr;
        itr it;
        it = this->buffer.begin();

        for(int i = 0; i < line_num -1; ++i)
        {   
            ++it;
        }

        this->buffer.insert(it, user_text);
        std::cout << "Cool, Your new line has been inserted." << '\n';
    }
    std::cout << '\n';
}

I am getting the following compile error:

error: no match for ‘operator=’ in ‘it = ((editor<std::basic_string<char> >*)this)->editor<std::basic_string<char> >::buffer.std::vector<_Tp, _Alloc>::begin [with _Tp = std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >, _Alloc = std::allocator<std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > > >, std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >*, std::vector<std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >, std::allocator<std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > > > > >, typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer = std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >*]()’ 

I have a feeling the compiler is getting confused with my typedef statement above but that is how I have seen to declare the correct iterator, but for some reason it is not working correctly. Any ideas?

  • 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-06-01T20:18:37+00:00Added an answer on June 1, 2026 at 8:18 pm

    If buffer is a std::vector< std::vector<T> > then buffer.begin() is a std::vector< std::vector<T> >::iterator or const_iterator, so your typedef doesn’t match.

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

Sidebar

Related Questions

I am attempting to create the following class name signature: public class MyClass<T> where
I'm attempting to create a generic controller, ie: public class MyController<T> : Controller where
I'm attempting to create a text-based version of this game . Code: #include <iostream>
I'm attempting to create a Parcelable class in Android so that I can pass
I'm attempting to create a type-agnostic vector in C++ that is distinguished by two
Attempting to create a filter select to find schedules with coursedates within a given
I'm attempting to create a recursive function that outputs a vector of strings that
I'm attempting to create a Product Engine for Apostrophe. I'm having trouble extending the
I am attempting to create an implode that given the following array: <?php $conditions
I'm attempting to create a PriorityQueue class in Java implemented via a Linked List.

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.