I have a sparse vector of type std::vector<SparseElement<T,I>>
where SparseElement is:
template<typename T, typename I = unsigned int>
struct SparseElement
{
I index;
T value;
//............
SparseElement &operator=(const std::pair<I,T> &pair);
}
Because I am using for filling the sparse vector a std::map<I,T>
which has as elements std::pair<I,T>
, I want a solution on this without changing the 'index' and 'value' members of SparseElement:
std::pair<I,T> a;
SparseElement<T,I> b;
b = a; // This is OK!
a = b; // Is there a solution on this problem?
// on containers:
std::vector<SparseElement<T,I>> vec;
std::map<I,T> m(vec.begin(), vec.end()); // Not working.
vec.assign(m.begin(), m.end()); // Working.