Stack Exchange
C++ bool std::operator < error with map with key std::unordered_set<int,std::hash<int>>
when I try to insert in this map:
std::map<std::unordered_set<int >, std::pair<float, std::pair<float, float >> >
I got this error

error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const
  std::_Tree<_Traits> &)' : could not deduce template argument for
  'const std::_Tree<_Traits> &' from 'const
  std::unordered_set,std::equal_to<_Kty>,std::allocator<_Kty>>'

My data is defined as follows:
    struct Trans {
    int Item;
    float Prob;
    float W;
};
bool operator<(const Trans &a, const Trans &b)
    {
        return a.Item < b.Item;
    }
    bool operator==( Trans c,  Trans d) { return c.Item == d.Item; }


    struct MyHash {
        size_t operator()(const Trans& x) const { return std::hash<int>()(x.Item);  }
    };


std::vector<std::vector<Trans>> data;
std::map<std::unordered_set<int>, float> S1;
std::map<std::unordered_set<int >, std::pair<float, std::pair<float, float >> > S2;
std::map<std::unordered_set<int >, std::pair<float, std::pair<float, float >> > S3;

The part that has the problem:
    do
        {

std::unordered_set<Trans, MyHash> KS(data[i].begin(), data[i].begin() + k);
std::unordered_set<int > elem;

float esupp = 1;
float Weight = 0;
float Wesupp = 1;
    for (auto const &iter : KS)
        {
          elem.insert(iter.Item);
           esupp *= iter.Prob;
          Weight += iter.W;
        }
        Weight = Weight / k;


        /*
        some code, and until here I didn't get any problem
        */

            **// This the area that has the problem** 

    S1[elem] = std::move(S1[elem] + esupp);
    Wesupp = Weight * S1[elem];
    S2[elem].first = std::move(S2[elem].first + esupp);
    S2[elem].second = std::make_pair(elem, Wesupp);
  } while (next_combination(data[i].begin(), data[i].begin() + k, data[i].end()));


What is the actual line that has the error?

Beyond the rest, this line doesn't look right: S2[elem].second = std::make_pair(elem, Wesupp);

I would seriously reconsider the data structure design... unordered_set as keys? std::pair<float, std::pair<float, float>>? (at least use a std::tuple or std::array<float, 3>)

@ben every line from  S1[elem] = std::move(S1[elem] + esupp) to  S2[elem].second = std::make_pair(elem, Wesupp); cause the error

@marco-a in the container S2 I would like to insert the unordered_set elem with its three float values. every round in the loop elem has unordered_set, if its similar to the previous one, I will update their three float values, otherwise I will insert new unordered_set with its three float values.

@t-c it's good suggestion but still I got the same error.

A std::map expects its key to implement the operator <, unless a comparator is supplied.
Your key type, std::unordered_set doesn't implement "less than".
As @T.C. mentions, you could use std::set instead of std::unordered_set.

thanks, but If I replace the std::map with std::unordered_map I will get another error, error C2338: The C++ Standard doesn't provide a hash for this type.

@Sandy I'll remove that suggestion then.  The cause for your error remains the same.  C++ does not support that.

std::set does have operator <() defined by the standard.

Thank you all, I need to use std::unordered_set not std::set because, I used hash function for checking if KS if super set of any of the previous set that stored in S2', I have file of 100k lines, each line has different size, and I used next_combinationfor generatingKS, and I used hashing for the comparisons part to reduce the time instead of using the STL includes() `

@Sandy Did you actually measure the speed with std::set / std::includes? When talking about performance, always measure.

@t-c yes, I did, and I test also by using profiler. in large data file, using has function is better than using std::includes. my problem is how to define S2 to carry the results.

Your current error, as Drew Dormann pointed out, is caused by std::unordered_set's lack of an operator <.
std::set, however, does have an overloaded operator <, so you can use that.
The problem with your code runs deeper than that, though. For instance:
S1[elem] = std::move(S1[elem] + esupp);

You are assigning a float. There's absolutely no point in using std::move, especially as S1[elem] + esupp is already an rvalue. The usual way of writing this line would be S1[elem] += esupp;
S2[elem].first = std::move(S2[elem].first + esupp);

Same problem.
S2[elem].second = std::make_pair(elem, Wesupp);

The LHS of the assignment is a std::pair<float, float>; the RHS creates a std::pair<std::unordered_set<int>, float>.
And as I mentioned in the comments, std::pair<float, std::pair<float, float>> is just bad design. It should be at least std::tuple or even better a std::array<float, 3> or even better a simple struct that makes clear what each of the three floats actually mean. 
Further, using a set<int> (unordered or not) as a key in a map is a fairly weird design. Do you want to just maintain a list of set<int>-3xfloat pairings that you can iterate through, or do you actually want to be able to efficiently index with a set<int>? If you don't need the efficient indexing, just use a vector of pairs rather than a map.

English is not my first language, so I used example to describe S2, I wish you have time to look at it. http://im67.gulfup.com/REB8Fj.png
