Q:

Error assignment of read-only location '__result.std::_Rb_tree_const_iterator<_Tp>::operator*()'

Some error while doing xor to all elements of a std::set.
below is partial code. Don't know much about std::transform. help pls :) 
    #include<bits/stdc++.h>
    #define ll long long int 

    using namespace std;

    int main()
    {
       set<ll> e1 ;//suppose i had inserted few elements in it!
       ll x2;
       cin>>x2;
       //now i want to xor all elements of set with x2.
       std::transform(std::begin(e1), std::end(e1), std::begin(e1), [=](ll x){return x2^x;});
       return 0;
     }

Error message: 

Error assignment of read-only location
  '__result.std::_Rb_tree_const_iterator<_Tp>::operator*()'

A:

You can't. A std::set doesn't allow in-place modification of its elements, so its iterators can never be written to. Thus, you can't use a std::set as the target of a std::transform.
You'd have to create a new set from the elements of the old, transforming as you go. (For example, by using a std::inserter as the target of the std::transform.)
Are you sure you can't just use std::vector?

