HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
10 /// \file
11 
12 #include "pxr/pxr.h"
13 
14 #include <type_traits>
15 #include <utility>
16 
18 
19 ////////////////////////////////////////////////////////////////////////////////
20 ///
21 /// \class VdfIteratorRange
22 ///
23 /// This class allows for construction of iterable ranges.
24 ///
25 template<typename Iterator>
27 {
28 public:
29 
30  /// Type of the elements this range gives access to.
31  ///
32  using value_type =
34 
35  /// Type of iterator used in the range.
36  ///
37  using iterator = Iterator;
38 
39  /// Type of constant iterator used in the range.
40  ///
41  using const_iterator = Iterator;
42 
43  /// Constructs an iterable range from a begin iterator.
44  ///
45  template <typename... Args>
46  VdfIteratorRange(Args&&... args) :
47  _begin(std::forward<Args>(args)...),
48  _end(_begin) {
49  _end.AdvanceToEnd();
50  }
51 
52  /// Constructs an iterable range from \p begin and \p end iterators.
53  ///
54  VdfIteratorRange(Iterator begin, Iterator end) : _begin(begin), _end(end) {}
55 
56  /// Returns an iterator to the beginning of the iterable range.
57  ///
58  Iterator begin() const {
59  return _begin;
60  }
61 
62  /// Returns an iterator to the end of the iterable range.
63  ///
64  Iterator end() const {
65  return _end;
66  }
67 
68  /// Returns \c true if the range is empty.
69  ///
70  bool IsEmpty() const {
71  return _begin == _end;
72  }
73 
74 private:
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 
85 
86 #endif
type
Definition: core.h:556
Iterator end() const
Definition: iteratorRange.h:64
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
VdfIteratorRange(Args &&...args)
Definition: iteratorRange.h:46
Iterator begin() const
Definition: iteratorRange.h:58
typename std::remove_cv< typename Iterator::value_type >::type value_type
Definition: iteratorRange.h:33
GLuint GLuint end
Definition: glcorearb.h:475
VdfIteratorRange(Iterator begin, Iterator end)
Definition: iteratorRange.h:54
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
**If you just want to fire and args
Definition: thread.h:618
bool IsEmpty() const
Definition: iteratorRange.h:70
Iterator const_iterator
Definition: iteratorRange.h:41