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:
Lioncash 2018-01-31 10:01:55 -05:00 committed by MerryMage
parent ab9b5fb8aa
commit 744495e23d

View file

@ -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};
} }