Vector.swap()



  • Hallo!

    Folgendes habe ich zur Swapfunktion gefunden

    **
    swap
    Syntax: void swap( vector &from );
    The swap() function exchanges the elements of the current vector with those of from.
    **

    Nun will ich einen Vektor kopieren und dachte mir das ich das per Swap machen könnte, nur leider leert er dann den Vector dessen Werte ich kopiere, wie die Funktion schon sagt wird halt getauscht, was aber nicht das ist was ich möchte.

    Gibt es evt. noch eine Copyfunktion oder muss ich das mit einer for-schleife machen?



  • schonmal mit einer zuweisung (op=) probiert?



  • Hi,

    MSDN schrieb:

    copy
    template<class InIt, class OutIt>
    OutIt copy(InIt first, InIt last, OutIt x);
    The template function evaluates *(x + N) = *(first + N)) once for each N in the range [0, last - first), for strictly increasing values of N beginning with the lowest value. It then returns x + N. If x and first designate regions of storage, x must not be in the range [first, last).

    MfG Eisflamme



  • Wenn eine einfache Zuweisung funktioniert bin ich total zufrieden! Danke für die Antworten!


Anmelden zum Antworten