c++ - how to convert map into set -
I have found some issues trying to change my map to a set, Chinson "object found:
std :: map & lt; Std :: string, Artiste * & gt; M_interpretes;
Here's how I add my * artist
to my map:
Zero Chanson :: addArtiste (artist * ) Throw (ExceptionArtiste, ExceptionLangueIncompatible) {if (a = zero!) {If (get-langue () to a => this-> getLangue ()) {m_interpretes.insert (pair , Artist *> (To do one & gt; union no (), a)); // m_interpretes [a-> gt; Union ()] = a; } And (exceptions are incompatible) (one, this); }}} Set & lt; Artiste * & gt; Chanson :: getArtistes () const {// set & lt; Artiste * & gt; Machin; Return Set & lt; Artiste * & gt; (M_interpretes.begin (), m_interpretes.end ()); }
I encountered this error due to this function:
Error C2664: 'std :: pair & lt; _Ty1, _Ty2> std :: set & lt; _Kty> :: Insert (Artist & amp): Impossible De Convert LE Paramester 1D Constitute :: Pair & lt; _Ty1, _Ty2> N 'Artist * & amp; Amp; C: \ Program Files (x86) \ microsoft Visual Studio 11.0 \ vc \ include \ set 179 1
How to fix any ideas?
You are trying to use std :: set
constructor, you Try to create an element from the evidence that passes the range:
Returns set & lt; Artiste * & gt; (M_interpretes.begin (), m_interpretes.end ());
But the element type of that category
std :: pair and lt; Const std :: string, artiste * & gt;
Which is definitely not convertible to Artiste *
, which is why you are not able to change that error, though you manually Can:
std :: set & lt; Artiste * & gt; S; For (Constant and Jodi: M_Interipetes) {SInstart (pair.second); }
Comments
Post a Comment