Container includes: generic includes algorithm : includes « STL Algorithms Merge « C++






Container includes: generic includes algorithm

  
 

#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
  bool result;

  string s("abcde");
  string s2("aeiou");

  vector<char> vector1(s.begin(), s.end());
  vector<char> vector2(s2.begin(), s2.end());

  // Illustrate includes:
  result = includes(vector1.begin(), vector1.end(),vector2.begin(), vector2.end());
  assert (result == false);

  result = includes(vector1.begin(), vector1.end(),vector2.begin(), vector2.begin() + 2);
  // 'a' and 'e' are contained in vector1
  assert (result == true);

  return 0;
}

        
    
  








Related examples in the same category

1.Determine whether one set is completely contained in another set
2.Use includes and search to check whether all elements in search are also in coll
3.Use includes() function to check if one set contains another set
4.Use includes() to check for subset