Skip to content

Instantly share code, notes, and snippets.

@loliGothicK
Created July 30, 2018 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loliGothicK/fcffa1ab13e60f11196a4e2713609284 to your computer and use it in GitHub Desktop.
Save loliGothicK/fcffa1ab13e60f11196a4e2713609284 to your computer and use it in GitHub Desktop.
#include <vector>
#include <tuple>
using namespace std;
int
main(){
vector< pair< std::string, int, int > > vec;
// 超ダサいし、読みにくいし、パフォーマンスも悪そうなコード
vec.push_back( make_tuple( "hoge", 1, 0 ) );
// コンストラクタに直接初期化子を完全転送して要素を構築
// 若干イケてるし、読みやすいし、パフォーマンスも良さそう
vec.emplace_back( "hoge", 1, 0 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment