2022-01-01から1年間の記事一覧

std::stringの受け取り方法による速度

C++

C++のムーブと右辺値参照を見直してたら勘違いしていた所あったので、引数の型による速度差を調べてみた。 [C++] gcc 12.1.0 - Wandbox 値渡しだとmoveしても遅いので参照で受ける必要がある。 (/ω\)ハズカシーィ

std::tupleの反復処理

C++

std::tupleで反復処理をさせる方法 #include <tuple> #include <string> #include <iostream> #include <utility> template <class Value> void print_value(std::ostream& stream, std::size_t index, const Value& value){ stream << "index(" << index << ") " << value << std::endl; } template </class></utility></iostream></string></tuple>