std::get
函數使用模板參數作爲常規參數。
作爲一個例子:爲什麼std :: get使用模板參數而不是常規參數?
std::tuple <int, double, long &, const char *> bar(18, 6.5, 12, "Hello!");
cout << std::get<2>(bar); // Print the tuple’s third element.
爲什麼此功能設計的這種方式?
爲什麼不使用常規參數呢?
例如,類似於:std::get(bar, 2)
或std::get(2, bar)
元組是一個編譯時構造。 – Rapptz