1,
set_difference(s1.begin(), s1.end(), s2.begin(), s2.end(),
std::inserter(s3, s3.begin()));
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Example: http://ideone.com/B4Cc1
By putting s3.begin()
as the output iterator, you would mean that you want to overwrite the front region of the set with the set difference. Overwriting requires the size of set being larger than the result, which is obviously not true most of the time; even if the set is not empty, you can't use s3.begin()
as output because the iterator is read-only (otherwise it would destroy the sorted order).
OTOH, std::inserter(x, cit)
means that, whenever this output iterator is assigned (*it = y
), the insert method will be called (x.insert(cit, y)
), which is what you really want: populate a set from empty.
2, coupon_type = atoi(req[string("coupon_type")].c_str());
funpoint.cc:619:31: error: passing ‘const std::map<std::basic_string<char>, std::basic_string<char> >’ as ‘this’ argument of ‘std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _C ompare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::bas ic_string<char>; _Tp = std::basic_string<char>; _Compare = std::less<std::basic_string<char> >; _All oc = std::allocator<std::pair<const std::basic_string<char>, std::basic_string<char> > >; std::map<_ Key, _Tp, _Compare, _Alloc>::mapped_type = std::basic_string<char>; std::map<_Key, _Tp, _Compare, _A lloc>::key_type = std::basic_string<char>]’ discards qualifiers [-fpermissive]