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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:01:14+00:00 2026-06-15T15:01:14+00:00

Please consider the following: // from main file // first arguement gets enc_array Rock

  • 0

Please consider the following:

// from main file

// first arguement gets enc_array
Rock rock (voice.getEncArray());
// getEncArray() gets a vector of vectors:
// std::vector<std::vector<unsigned int> > enc_array;

// in rock.hpp file, consider members
Rock( const std::vector<std::vector<unsigned int> > &);

std::vector<std::vector<unsigned int> * > remaining;

const std::vector<std::vector<unsigned int> > * population;

// in rock.cpp
Rock::Rock ( const vector<vector<unsigned int> > & v) :
  population (&v),
  ....

// in one of the class member functions
for ( vector<vector<unsigned int> >::const_iterator ci = population->begin(); ci != population->end(); ++ci ) {
    // for some indexes...
    remaining.push_back (& (*ci));      // <------  PROBLEM
}

gcc reports:

error: no matching function for call to 'std::vector<std::vector<unsigned int>*>::push_back(const std::vector<unsigned int>*)'

note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<unsigned int>*; _Alloc = std::allocator<std::vector<unsigned int>*>; std::vector<_Tp, _Alloc>::value_type = std::vector<unsigned int>*] <near match>

note:   no known conversion for argument 1 from 'const std::vector<unsigned int>*' to 'std::vector<unsigned int>* const&'

I understand that I’m trying to push the addresses of vector<int> that were considered const to a non-const vector.
After remaining is filled-up, no other method will change its data, so in fact it should be const.
But I cannot declare remaining as a const vector, as it would give an error.

error: no matching function for call to 'std::vector<std::vector<unsigned int>*>::push_back(const std::vector<unsigned int>*) const'

note: candidate is:
note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<unsigned int>*; _Alloc = std::allocator<std::vector<unsigned int>*>; std::vector<_Tp, _Alloc>::value_type = std::vector<unsigned int>*] <near match>

note:   no known conversion for argument 1 from 'const std::vector<unsigned int>*' to 'std::vector<unsigned int>* const&'

Do I really need to copy elements from population to remaining? Or is there anything else I can do in order not to have this overhead?

  • 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-15T15:01:15+00:00Added an answer on June 15, 2026 at 3:01 pm

    Try

    std::vector<const std::vector<unsigned int> *> remaining;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please consider the following context from Innate : # Default application for Innate def
Please consider the following example code (from the lm doc): ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt
Please consider the following code and the explanation from this Mozilla tutorial Using web
Please consider the following snippet from an implementation of the Interpreter pattern: public override
Please consider the following: I am storing around 1.2 Million TIF files ranging from
Please consider the following piece of code: int main() { typedef boost::ptr_vector<int> ptr_vector; ptr_vector
Please consider the following: $query = SELECT legIDs FROM trip; $result = mysql_query($query) or
Please consider the following: declare @abbrev varchar(20); set @abbrev=''; select pk_term into #t2 from
Please consider the following example: #include <string> #include <vector> using std::string; using std::vector; template
Please consider the following, from the followings from Can we generate "foveated Image" 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.