From the standard, std::includes
:
Returns:
true
if[first2, last2)
is empty or if every element in the range
I believe you're trying to check if a
includes b
in your example, a
doesn't include b
but b
does include a
. If you swap b
and a
it will return true, since a
is included in b
.
I hope I'm not missing something obvious.
#include
#include
#include
int main() {
std::vector a({1});
std::vector b({1,1,1});
// Outputs 'true'
std::cout << std::boolalpha
<< std::includes(b.begin(), b.end(), a.begin(), a.end()) << '\n';
}
What I've understood by playing around with algorithm is, when you type includes(R2, R1)
it checks if R2
owns R1
as a subgroup, if yes returns true
if not returns false
. Also if it's not ordered throws an error: sequence not ordered
.