Binary Search for 2D vector

I am trying to write code for Binary search program on a 2D vector. I tried code. But I can't understand what is the error I have got. I have given below my code and errors.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 class BINARY_ON
{
	public:
  explicit BINARY_ON(int column,string fCol) :m_column(column),fColType(fCol) {}
 
  bool operator()(const string& lhs,const vector<string>& rhs)
  {

	if(fColType=="number")
		return atoi(lhs.c_str()) < atoi(rhs[m_column].c_str());					
	else if(fColType=="date")
		return PPCheckTwoDate(lhs, rhs[m_column])<0;
	else
		return lhs < rhs[m_column];	
   }
   private:
   int m_column;
   string fColType;
 
};

int main ()
{
vector<vector<string>> table_data;

// Vector Data Insert

	BINARY_ON compare_column(4,"date");
	
	if (std::binary_search (table_data.begin(), table_data.end(), "01051996", compare_column))
    std::cout << "found!\n"; else std::cout << "not found.\n";
}


I got the below errors.

/usr/include/c++/4.6/bits/stl_algo.h:2416:4: error: no match for call to ‘(PPBINARY_ON) (std::vector<std::basic_string<char> >&, const char [9])’
note: bool PPBINARY_ON::operator()(const string&, const std::vector<std::basic_string<char> >&)
note: no known conversion for argument 1 from ‘std::vector<std::basic_string<char> >’ to ‘const string& {aka const std::basic_string<char>&}’


Last edited on
closed account (Dy7SLyTq)
your going to have to forgive my lack of knowledge but if there is one thing im good at its reading errors and there are some things ive noticed: your compiler is g++ 4.6. could that be the problem? and as to the error: it looks like your trying to convert between vector<string> and string
Topic archived. No new replies allowed.