Something like that ? 
struct classcomp {
bool operator() ( const S &  & lhs, const S& rhs) const
{return lhs.i( )< rhs.i( );} 
}; 
set<int, classcomp> s(v.begin(), v.end());