Loading...
Searching...
No Matches
iteratorRange.h
Go to the documentation of this file.
1//
2// Copyright 2025 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_EXEC_VDF_ITERATOR_RANGE_H
8#define PXR_EXEC_VDF_ITERATOR_RANGE_H
9
11
12#include "pxr/pxr.h"
13
14#include <type_traits>
15#include <utility>
16
17PXR_NAMESPACE_OPEN_SCOPE
18
25template<typename Iterator>
27{
28public:
29
32 using value_type =
33 typename std::remove_cv<typename Iterator::value_type>::type;
34
37 using iterator = Iterator;
38
41 using const_iterator = Iterator;
42
45 template <typename... Args>
46 VdfIteratorRange(Args&&... args) :
47 _begin(std::forward<Args>(args)...),
48 _end(_begin) {
49 _end.AdvanceToEnd();
50 }
51
54 VdfIteratorRange(Iterator begin, Iterator end) : _begin(begin), _end(end) {}
55
58 Iterator begin() const {
59 return _begin;
60 }
61
64 Iterator end() const {
65 return _end;
66 }
67
70 bool IsEmpty() const {
71 return _begin == _end;
72 }
73
74private:
75
76 // The begin iterator of this range.
77 Iterator _begin;
78
79 // The end iterator of this range.
80 Iterator _end;
81
82};
83
84PXR_NAMESPACE_CLOSE_SCOPE
85
86#endif
This class allows for construction of iterable ranges.
Iterator iterator
Type of iterator used in the range.
Iterator begin() const
Returns an iterator to the beginning of the iterable range.
typename std::remove_cv< typename Iterator::value_type >::type value_type
Type of the elements this range gives access to.
Iterator end() const
Returns an iterator to the end of the iterable range.
bool IsEmpty() const
Returns true if the range is empty.
VdfIteratorRange(Iterator begin, Iterator end)
Constructs an iterable range from begin and end iterators.
Iterator const_iterator
Type of constant iterator used in the range.
VdfIteratorRange(Args &&... args)
Constructs an iterable range from a begin iterator.
STL namespace.