- iterator[meta header]
- std[meta namespace]
- type-alias[meta id-type]
- cpp20[meta cpp]
namespace std {
template<dereferenceable I>
requires requires(I& i) {
{ ranges::iter_move(i) } -> can-reference;
}
using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<I&>()));
}
- dereferenceable[link /reference/iterator/dereferenceable.md]
- can-reference[link /reference/iterator/dereferenceable.md]
- iter_move[link /reference/iterator/iter_move.md]
- declval[link /reference/utility/declval.md]
任意のイテレータ型I
から、そのイテレータの要素への右辺値参照型を取得する。
#include <iostream>
#include <iterator>
#include <vector>
int main() {
using vec_iterator = std::vector<int>::iterator;
using pointer = double*;
static_assert(std::same_as<std::iter_rvalue_reference_t<vec_iterator>, int&&>);
static_assert(std::same_as<std::iter_rvalue_reference_t<pointer> , double&&>);
}
- std::iter_rvalue_reference_t[color ff0000]
- C++20
- Clang: ??
- GCC: 10.1 [mark verified]
- Visual C++: 2019 Update 6 [mark verified]