[ Web Proxy ]
URL:
Viewing: https://fr.cppreference.com/cpp/algorithm/copy_n [Back]  [Original]

std::copy_n cppreference.com
cppreference.com
Espaces de noms
Variantes

std::copy_n

De cppreference.com

<metanoindex/>

 
 
Bibliothque d'algorithmes
Fonctions
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Non-modification de la squence des oprations
Original:
Non-modifying sequence operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Modification de la squence des oprations
Original:
Modifying sequence operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Des oprations de partitionnement
Original:
Partitioning operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Oprations de tri (sur les gammes tris)
Original:
Sorting operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
is_sorted (C++11)
is_sorted_until (C++11)
sort
Oprations binaires de recherche (sur les gammes tris)
Original:
Binary search operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Dfinir les oprations (sur les gammes tris)
Original:
Set operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Oprations Heap
Original:
Heap operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Minimum / maximum de fonctionnement
Original:
Minimum/maximum operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Oprations numriques
Original:
Numeric operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Bibliothque C
Original:
C library
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
<tbody> </tbody>
Dclar dans l'en-tte <algorithm>
template< class InputIt, class Size, class OutputIt > OutputIt copy_n( InputIt first, Size count, OutputIt result );
Copie exactement count valeurs du dbut de la plage first au dbut de la plage result, si count>0. Ne fait rien autrement .
Original:
Copies exactly count values from the range beginning at first to the range beginning at result, if count>0. Does nothing otherwise.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Paramtres

first -
le dbut de la srie d'lments copier
Original:
the beginning of the range of elements to copy from
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
count -
nombre d'lments copier
Original:
number of the elements to copy
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
result -
le dbut de la plage de destination
Original:
the beginning of the destination range
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Type requirements
-
InputIt must meet the requirements of InputIterator.
-
OutputIt must meet the requirements of OutputIterator.

Retourne la valeur

Iterator dans la plage de destination, pointant aprs le dernier lment copi ou si count>0 first autrement .
Original:
Iterator in the destination range, pointing past the last element copied if count>0 or first otherwise.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Complexit

Exactement count missions, si count>0 .
Original:
Exactly count assignments, if count>0.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Mise en uvre possible

template< class InputIt, class Size, class OutputIt>
OutputIt copy_n(InputIt first, Size count, OutputIt result)
{
    if (count > 0) {
        *result++ = *first;
        for (Size i = 1; i < count; ++i) {
            *result++ = *++first;
        }
    }
    return result;
}

Exemple

#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>

int main()
{
    std::string in = "1234567890";
    std::string out;

    std::copy_n(in.begin(), 4, std::back_inserter(out));
    std::cout << out << '\n';
}

Rsultat :

1234

Voir aussi


(C++11)
Copie une srie d'lments vers un nouvel emplacement
Original:
copies a range of elements to a new location
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction gnrique) [edit]

Web Proxy Viewer  |  New URL  |  Original Page