Insert into any sorted container
When we use std::begin() and std::end(), we should always consider whether we actually want to use begin() and end() of the type's namespace instead (argument-dependent lookup, aka ADL), with fallback to std:
using std::begin();
using std::end();
return c.insert(std::upper_bound(begin(c), end(c), item, comp),
                std::forward&lt;T&gt;(item));


When we're inserting to a sorted container such as std::set, we probably want to use the container's key_compare as default, rather than std::less&lt;T&gt;.  I suspect that will require splitting back into two functions again.