You must make Foo::comparator
static or wrap it in a std::mem_fun
class object. This is because lower_bounds()
expects the comparer to be a class of object that has a call operator, like a function pointer or a functor object. Also, if you are using C++11 or later, you can also do as dwcanillas suggests and use a lambda function. C++11 also has std::bind
too.
Examples:
// Binding: std::lower_bounds(first, last, value, std::bind(&Foo::comparitor, this, _1, _2)); // Lambda: std::lower_bounds(first, last, value, [](const Bar & first, const Bar & second) { ret
Related Posts:
- C++ — expected primary-expression before ‘ ‘
- Return array in a function
- What is meant with “const” at end of function declaration? [duplicate]
- Meaning of = delete after function declaration
- Difference between `constexpr` and `const`
- What is the difference between const int*, const int * const, and int const *?
- What is the difference between const int*, const int * const, and int const *?
- Difference between const reference and normal parameter
- How to convert a std::string to const char* or char*
- Reverse Contents in Array
- What is the difference between a static and const variable?
- c++: No instance of overloaded function
- error: expected primary-expression before ‘)’ token (C)
- How can I convert const char* to string and then back to char*?
- How to create a dynamically-allocated array of const objects, but have values assigned to them?
- C++: Expression must have a constant value when declaring array inside function
- What is the difference between const_iterator and non-const iterator in the C++ STL?
- error: “initializer expression list treated as compound expression”
- Getting error: ISO C++ forbids declaration of with no type
- Function for C++ struct
- c++ –
- What does it mean that “a declaration shadows a parameter”?
- C++ – statement cannot resolve address for overloaded function
- How do I return a char array from a function?
- How to return a struct from a function in C++?
- Why can’t we pass arrays to function by value?
- How to sort with a lambda?
- template argument deduction/substitution failed, when using std::function and std::bind
- non-member function cannot have cv-qualifier
- ERROR: Control may reach end of non-void function /
- function does not take 1 arguments c++
- C++ correct way to return pointer to array from function
- Where to declare/define class scope constants in C++?
- Use of ‘const’ for function parameters
- Difference between function arguments declared with & and * in C++
- Is C++ Array passed by reference or by pointer?
- “cannot be used as a function error”
- Is “delete this” allowed in C++?
- How to create a dynamic array of integers
- How do I build a graphical user interface in C++? [closed]
- How to dynamically allocate arrays in C++
- What does (~0L) mean?
- How to throw a C++ exception
- How to fix C++ error: expected unqualified-id
- How to track down a “double free or corruption” error
- Error: “expression must have integral or unscoped enum type” [duplicate]
- How to fix C++ error: expected unqualified-id
- Reading from file in c++ ifstream
- How do I iterate over the words of a string?
- C++ IDE for Macs
- C++ Error: No match for ‘operator=’
- How to fix ‘No match for operator[]’ error (c++)
- std::cin.getline( ) vs. std::cin
- Inheriting constructors
- Vector is not a Template?
- Displaying a vector of strings in C++
- ‘vector’ in namespace ‘std’ does not have a template type
- Floating Point Exception C++ Why and what is it?
- Issue with std::stol – ‘std::invalid_argument’ what(): stol
- Writing a LinkedList destructor?
- “Symbol(s) not found for architecture x86_64” on QtCreator project
- Is “argv[0] = name-of-executable” an accepted standard or just a common convention?
- How to fix ‘std::logic_error’ what(): basic_string::_M_construct null not valid error?
- What does the assignment of ~0u to a variable mean in C++?
- expected expression in C++?
- How to access the contents of a vector from a pointer to the vector in C++?
- printf with std::string?
- General way of solving Error: Stack around the variable ‘x’ was corrupted
- error MSB3073: How do I fix this?
- timestamp of time(0) at multiple places in a C++ program
- What’s the most efficient way to erase duplicates and sort a vector?
- How can I iterate through a string and also know the index (current position)?
- c++ parse int from string [duplicate]
- C++ array assign error: invalid array assignment
- Is there a median function in the C++ library?
- how to initialize an empty integer array in c++
- What does |= mean in c++
- Error: cannot declare variable ‘c’ to be of abstract type ‘circle’
- Static linking vs dynamic linking
- What is object slicing?
- Java equivalent of cin (C++)
- g++ “because the following virtual functions are pure” with abstract base class
- why can’t I dereference an iterator?
- expected identifier before string constant
- C++ error: expected identifier before “(” token
- C++ error: double free or corruption (fasttop)
- How does c++ represent negative value
- error: switch quantity not an integer
- How to create a vector of class objects in C++?
- Is clrscr(); a function in C++?
- Cross compiler prefix and path in eclipse
- Use of undefined type [duplicate]
- Warning : overflow in implicit constant conversion
- C++ multiline string literal
- Getting a bunch of crosses initialization error
- c++ a heap has been corrupted error when running the program
- Expected unqualified-id before ‘[‘ token
- C++ Error: Invalid conversion from ‘char’ to ‘const char*’
- Get Current Time in mm/dd/yyyy in C++
- “please check gdb is codesigned – see taskgated(8)” – How to get gdb installed with homebrew code signed?