473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Use pop_back() operator on a multimap of vector<int>

I am attempting to access the last member of the a vector which is the second part of the pair<string, vector<int>>. The following code snippet shows what I am attempting:

typedef std::multimap<std::string, p_sym_data> table_type;
typedef std::multimap<int, mark_type> table_type_i;

int calc_short(int nt, string nt_s, table_type *gsd, table_type *once, table_type_i *mark)
{

int pn=gsd->find(nt_s)->second[1];
table_type::iterator on;
table_type_i::iterator mk;

mk=mark->find(pn);
mk->second.push_back(true);
on=once->find(nt_s);
int a=on->second.pop_back();

return pn;

}

The following compile-time error is provided (gcc 4.1.2 20070626):

utilities.cpp: In function ‘int calc_short(int, std::string, table_type*, table_type*, table_type_i*)’:
utilities.cpp:59: error: void value not ignored as it ought to be
make: *** [utilities.o] Error 1

The error refers to the line just before the return statement. I believe that I should be able to do this based on some other examples I've googled. Any ideas as to why I cannot access the vector member in this way?
Dec 28 '07 #1
1 2591
gpraghuram
1,275 Expert 1GB
I am attempting to access the last member of the a vector which is the second part of the pair<string, vector<int>>. The following code snippet shows what I am attempting:

typedef std::multimap<std::string, p_sym_data> table_type;
typedef std::multimap<int, mark_type> table_type_i;

int calc_short(int nt, string nt_s, table_type *gsd, table_type *once, table_type_i *mark)
{

int pn=gsd->find(nt_s)->second[1];
table_type::iterator on;
table_type_i::iterator mk;

mk=mark->find(pn);
mk->second.push_back(true);
on=once->find(nt_s);
int a=on->second.pop_back();

return pn;

}

The following compile-time error is provided (gcc 4.1.2 20070626):

utilities.cpp: In function ‘int calc_short(int, std::string, table_type*, table_type*, table_type_i*)’:
utilities.cpp:59: error: void value not ignored as it ought to be
make: *** [utilities.o] Error 1

The error refers to the line just before the return statement. I believe that I should be able to do this based on some other examples I've googled. Any ideas as to why I cannot access the vector member in this way?

pop_back operation erases the last element of the vector.
Thats why you are getting the error.
For more info on it read this page

Thanks
Raghuram.

Raghuram
Dec 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Andreas Krueger | last post by:
Hi! I am fed up with vector<int> iv; iv.push_back(42); iv.push_back(9); iv.push_back(11); ... and would rather use a function "fillVector": vector<int> iv = fillVector(42,9,11); like...
3
by: Erik Borgstr?m | last post by:
Hi, Yes, I have followed some of the discussion on vector<vector<int> >, but perhaps I'm just blind. I want to use a vector<vector<int> > of outer size n and inner size m. Are these correct ways...
1
by: Alex Vinokur | last post by:
------ foo.cpp ------ #include <vector> using namespace std; int main() { const vector<int> v1 (10); const vector<bool> v2 (10); &v1;
20
by: Anonymous | last post by:
Is there a non-brute force method of doing this? transform() looked likely but had no predefined function object. std::vector<double> src; std::vector<int> dest; ...
5
by: pmatos | last post by:
Hi all, I have a vector of vector of ints, I could use C approach by using int but I think C++ vector<vector<int> > would be easier to manage. So I have a function which creates and initializes...
2
by: danielhdez14142 | last post by:
Some time ago, I had a segment of code like vector<vector<int example; f(example); and inside f, I defined vector<int>'s and used push_back to get them inside example. I got a segmentation...
0
by: citystud | last post by:
does C# support vector< vector<int> > ?if not how can i use vector?
10
by: arnuld | last post by:
It is quite an ugly hack but it is all I am able to come up with for now :-( and it does the requires work. I want to improve the program, I know you people have much better ideas ;-) /* C++...
10
by: arnuld | last post by:
WANTED: /* C++ Primer - 4/e * * Exercise: 9.26 * STATEMENT * Using the following definition of ia, copy ia into a vector and into a list. Use the single iterator form of erase to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.