va_copy
提供: cppreference.com
|
|
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
| Defined in header <cstdarg>
|
| void va_copy(va_list dest, va_list src); |
(C++11およびそれ以降) | |
va_copyマクロコピーsrcへ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.
You can help to correct and verify the translation. Click here for instructions.
va_endは、関数の戻り値や
destの後続の再初期化(destまたはva_startの呼び出しを介して)の前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.
You can help to correct and verify the translation. Click here for instructions.
目次 |
[編集] パラメータ
| dest | - | 初期化するva_listタイプのインスタンス
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 | - | va_listを初期化するために使用されるソース
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. |
[編集] 値を拡大しました
(なし)
[編集] 例
このコードを実行します
#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'; }
出力:
0.920258
[編集] 参照
| 可変個引数の関数の引数にアクセスできるようになります 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. (関数マクロ) | |
| 次の可変個引数の関数の引数にアクセスします 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. (関数マクロ) | |
| 可変個引数の関数の引数のトラバーサルは終了します 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. (関数マクロ) | |

