-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
#include <iterator> | ||
|
||
namespace le { | ||
template <typename It> | ||
struct Reversed { | ||
It first{}; | ||
It last{}; | ||
|
||
constexpr auto begin() const { return std::reverse_iterator<It>{first}; } | ||
constexpr auto end() const { return std::reverse_iterator<It>{last}; } | ||
}; | ||
|
||
template <typename It> | ||
constexpr auto reverse_view(It first, It last) { | ||
return Reversed<It>{first, last}; | ||
} | ||
|
||
template <typename ContainerT> | ||
constexpr auto reverse_view(ContainerT&& container) { | ||
return reverse_view(std::end(container), std::begin(container)); | ||
} | ||
} // namespace le |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters