Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c++ - Remove element from vector of maps -


i have vector of maps:

typedef map<string, string> amap; typedef vector<amap> rvec; rvec rows; 

how can remove elements rows?

the following code not work.

struct remove_it {   bool operator() (rvec& rows)   {     // validation code here!    } };  rvec::iterator = remove(rows.begin(), rows.end(), remove_it()); rows.erase(it, rows.end()); 

i got following error.

error: no matching function call 'remove(std::vector<s td::map<std::basic_string<char>, std::basic_string<char> > >::iterator, std::vec tor<std::map<std::basic_string<char>, std::basic_string<char> > >::iterator, mai n(int, char**)::remove_it)' 

thanks.

1) first off: please provide single compilable example.
code posted above problematic rvec , rowsvector have been interchanged (you have seen if had posted real code).

2) using wrong remove. should remove_if

3) normal functor const

4) operator() should object of type amap (as in vector) not reference vector.

5) don't lazy add std:: in-front of objects in standard namespace.
rather using using namespace std;

#include <map> #include <vector> #include <string> #include <algorithm>  typedef std::map<std::string, std::string> amap; typedef std::vector<amap>        rvec;  rvec rows;  struct remove_it {                  // corrected type here   bool operator() (amap const& row) const  // const here   {     // validation code here!     return true;   } };  int main() {                                  // _if herer     rvec::iterator = std::remove_if(rows.begin(), rows.end(), remove_it());     rows.erase(it, rows.end()); } 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -