-
I have a class template:
template<class idxT> class SimpleGraph { private: // ... std::set<std::pair<idxT,idxT>> edgeSet; // ... void addEdge(idxT a, idxT b); // ... } - I need to use the return of
edgeSet.emplace(a,b)insideaddEdge(), which is denoted asrin the following. -
The declaration and the assignment of
rneed to be separated since the value ofaandbis determined by a if-else statement. Thus, I cannot useauto r = edgeSet.emplace(a,b); -
I tried the following strategies but neither is successful. The first one is
std::pair<decltype(edgeSet)::iterator,bool> r; // some code r = edgeSet.emplace(a,b);The second one is
// inside class template typedef std::set<std::pair<idxT,idxT>> EdgeSetType; EdgeSetType edgeSet; // inside definition of `addEdge()` std::pair<EdgeSetType::iterator,bool> r; // some code r = edgeSet.emplace(a,b);
How can I declare the return of edgeSet.emplace(a,b)?
Aucun commentaire:
Enregistrer un commentaire