Espaços nominais
Variantes
Acções

va_copy

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

 
 
Biblioteca de utilitários
Digite apoio (basic types, RTTI, type traits)
Gerenciamento de memória dinâmica
De tratamento de erros
Utilidades do programa
Variadic funções
Data e hora
Objetos de função
(C++11)
Os operadores relacionais
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>=
Pares e tuplas
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.
(C++11)
Troque, avançar e avançar
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.
(C++11)
(C++11)
(C++11)
 
 
Definido no cabeçalho <cstdarg>
void va_copy(va_list dest, va_list src);
(desde C++11)
As cópias va_copy macro src para 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 deve ser chamado em dest antes do retorno de função ou qualquer subseqüentes re-inicialização do dest (via chamadas para va_start ou 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.

Índice

[editar] Parâmetros

dest -
uma instância do tipo va_list para inicializar
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 -
o va_list fonte que será usado para inicializar 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.

[editar] Expandiu valor

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

[editar] Exemplo

#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';
}

Saída:

0.920258

[editar] Veja também

permite o acesso a argumentos de função variádicos
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.

(função macro) [edit]
acessa o argumento da função próximo aridade
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.

(função macro) [edit]
termina travessia dos argumentos da função variádicos
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.

(função macro) [edit]