Namespace
Varianti

va_copy

Da cppreference.com.
< cpp‎ | utility‎ | variadic

 
 
Utilità libreria
Tipo di supporto (basic types, RTTI, type traits)
Gestione della memoria dinamica
La gestione degli errori
Programma di utilità
Funzioni variadic
Data e ora
Funzione oggetti
initializer_list(C++11)
bitset
hash(C++11)
Gli operatori relazionali
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
Coppie e tuple
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pair
tuple(C++11)
piecewise_construct_t(C++11)
piecewise_construct(C++11)
Swap, in avanti e spostare
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
swap
forward(C++11)
move(C++11)
move_if_noexcept(C++11)
declval(C++11)
 
 
Elemento definito nell'header <cstdarg>
void va_copy(va_list dest, va_list src);
(dal C++11)
Le copie macro va_copy src a dest.
Original:
The va_copy macro copies src to dest.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
va_end dovrebbero essere chiamati dest prima del ritorno di funzione o di qualsiasi successiva re-inizializzazione di dest (tramite chiamate a va_start o va_copy).
Original:
va_end should be called on dest before the function returns or any subsequent re-initialization of dest (via calls to va_start or va_copy).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Indice

[modifica] Parametri

dest -
un'istanza del tipo va_list per inizializzare
Original:
an instance of the va_list type to initialize
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
src -
il va_list origine che verrà utilizzato per inizializzare dest
Original:
the source va_list that will be used to initialize dest
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifica] Expanded valore

(Nessuno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifica] Esempio

#include <iostream>
#include <cstdarg>
#include <cmath>
 
double sample_stddev(int count, ...) 
{
    double sum = 0;
    va_list args1;
    va_start(args1, count);
    va_list args2;
    va_copy(args2, args1);
    for (int i = 0; i < count; ++i) {
        double num = va_arg(args1, double);
        sum += num;
    }
    double mean = sum / count;
 
    double sum_sq_diff = 0;
    for (int i = 0; i < count; ++i) {
        double num = va_arg(args2, double);
        sum_sq_diff += (num-mean) * (num-mean);
    }
    return std::sqrt(sum_sq_diff / count);
}
 
int main() 
{
    std::cout << sample_stddev(4, 25.0, 27.3, 26.9, 25.7) << '\n';
}

Output:

0.920258

[modifica] Vedi anche

consente l'accesso agli argomenti della funzione variadic
Original:
enables access to variadic function arguments
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(funzione macro) [modifica]
accede l'argomento successivo funzione variadic
Original:
accesses the next variadic function argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(funzione macro) [modifica]
termina attraversamento degli argomenti della funzione variadic
Original:
ends traversal of the variadic function arguments
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(funzione macro) [modifica]