std::ignore
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <tuple> で定義
|
||
const /*unspecified*/ ignore; |
(C++11以上) (C++17未満) |
|
inline constexpr /*unspecified*/ ignore; |
(C++17以上) | |
任意の値を効果なく代入することができる未規定な型のオブジェクトです。 std::tuple を分解するときに、使用されない引数のためのプレースホルダとして、 std::tie で使用することが意図されています。
例
set.insert() から返されるペアを分解し、ブーリアンだけを保存します。
Run this code
#include <iostream>
#include <string>
#include <set>
#include <tuple>
int main()
{
std::set<std::string> set_of_str;
bool inserted = false;
std::tie(std::ignore, inserted) = set_of_str.insert("Test");
if (inserted) {
std::cout << "Value was inserted successfully\n";
}
}
出力:
Value was inserted successfully
関連項目
左辺値参照の tuple を作成したり、タプルを個々のオブジェクトに分解したりします (関数テンプレート) |