-
Notifications
You must be signed in to change notification settings - Fork 18
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
2 changed files
with
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef OPENSMT_VIEW_H | ||
#define OPENSMT_VIEW_H | ||
|
||
#include <ranges> | ||
|
||
namespace opensmt { | ||
|
||
template<typename V> | ||
class VectorView : public std::ranges::view_interface<VectorView<V>> { | ||
public: | ||
using Vector = V; | ||
using Iterator = typename Vector::const_iterator; | ||
|
||
VectorView() = default; | ||
VectorView(Vector const & vec) : VectorView(vec.cbegin(), vec.cend()) {} | ||
VectorView(Iterator begin_, Iterator end_) : _begin(begin_), _end(end_) {} | ||
|
||
Iterator begin() const { return _begin; } | ||
Iterator end() const { return _end; } | ||
|
||
private: | ||
Iterator _begin{}; | ||
Iterator _end{}; | ||
}; | ||
|
||
} // namespace opensmt | ||
|
||
#endif // OPENSMT_VIEW_H |
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