// Example program
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <algorithm>
struct cmp {
bool operator()(std::string i, const std::pair<std::string,std::string>& p) const
{
return i < p.first;
}
bool operator()(const std::pair<std::string, std::string>& p, std::string i) const
{
return p.first < i;
}
};
int main(){
std::set<std::string> s1 {"--name", "--id"}; //Conditionally defined mandatory parameters
std::map<std::string, std::string> s2 { {"--name","Admin"}, {"--group","Group1"}}; //options given by user
std::set<std::string> result;
std::set_difference(s1.begin(), s1.end(), s2.begin(), s2.end(),
std::inserter(result, result.end()), cmp());
std::cout << *result.begin();
}
I'd want the output to be such that if user has missed any one of the mandatory parameters it should throw error, at the same time if user has mentioned any extra parameter other than the mandatory args an error is again expected.
Also set_symmetric_difference fails to work with it.