iterator_util: Make Reverse constexpr
C++17 makes non-member rbegin(), rend(), crbegin(), and crend() constexpr, allowing this to also be constexpr.
This commit is contained in:
parent
ab9b5fb8aa
commit
744495e23d
1 changed files with 3 additions and 3 deletions
|
@ -15,12 +15,12 @@ template<typename T>
|
||||||
struct ReverseAdapter {
|
struct ReverseAdapter {
|
||||||
T& iterable;
|
T& iterable;
|
||||||
|
|
||||||
auto begin() {
|
constexpr auto begin() {
|
||||||
using namespace std;
|
using namespace std;
|
||||||
return rbegin(iterable);
|
return rbegin(iterable);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto end() {
|
constexpr auto end() {
|
||||||
using namespace std;
|
using namespace std;
|
||||||
return rend(iterable);
|
return rend(iterable);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ struct ReverseAdapter {
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
detail::ReverseAdapter<T> Reverse(T&& iterable) {
|
constexpr detail::ReverseAdapter<T> Reverse(T&& iterable) {
|
||||||
return detail::ReverseAdapter<T>{iterable};
|
return detail::ReverseAdapter<T>{iterable};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue