名前空間
変種

std::ignore

提供: cppreference.com
 
 
ユーティリティライブラリ
汎用ユーティリティ
日付と時間
関数オブジェクト
書式化ライブラリ (C++20)
(C++11)
関係演算子 (C++20で非推奨)
整数比較関数
(C++20)
スワップと型操作
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
一般的な語彙の型
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

初等文字列変換
(C++17)
(C++17)
 
 
<tbody> </tbody>
ヘッダ <tuple> で定義
const /*unspecified*/ ignore;
(C++11以上)
(C++17未満)
inline constexpr /*unspecified*/ ignore;
(C++17以上)

任意の値を効果なく代入することができる未規定な型のオブジェクトです。 std::tuple を分解するときに、使用されない引数のためのプレースホルダとして、 std::tie で使用することが意図されています。

set.insert() から返されるペアを分解し、ブーリアンだけを保存します。

#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 を作成したり、タプルを個々のオブジェクトに分解したりします
(関数テンプレート) [edit]