namespace std::ranges {
template<class F, class Tuple>
constexpr void tuple-for-each(F&& f, Tuple&& t) {
apply([&]<class... Ts>(Ts&&... elements) {
(static_cast<void>(invoke(f, std::forward<Ts>(elements))), ...);
}, std::forward<Tuple>(t));
}
}
概要
tuple-for-each は、tupleの各要素に対して関数を適用する説明専用の関数テンプレートである。
バージョン
言語
- C++23
参照
- N4950 26 Ranges library
- LWG Issue 3755. tuple-for-each can call user-defined
operator,- C++23で、
invokeの呼び出しをstatic_cast<void>(...)で包み、ユーザー定義のoperator,が呼ばれないよう修正された
- C++23で、