HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
string_view.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenImageIO project.
2 // SPDX-License-Identifier: Apache-2.0
3 // https://github.com/AcademySoftwareFoundation/OpenImageIO
4 
5 // clang-format off
6 
7 #pragma once
8 
9 #include <algorithm>
10 #include <cstddef>
11 #include <cstring>
12 #include <limits>
13 #include <ostream>
14 #include <stdexcept>
15 #include <string>
16 
17 #include <OpenImageIO/export.h>
19 #include <OpenImageIO/platform.h>
20 #include <OpenImageIO/detail/fmt.h>
21 
22 // Some compilers already have a string_view pre-C++17
23 // N.B. This logic is taken from fmtlib.
24 #if (__has_include(<string_view>) && \
25  (__cplusplus > 201402L || defined(_LIBCPP_VERSION))) || \
26  (defined(_MSVC_LANG) && _MSVC_LANG > 201402L && _MSC_VER >= 1910)
27 # include <string_view>
28 # define OIIO_STD_STRING_VIEW_AVAILABLE
29 #elif __has_include("experimental/string_view")
30 # include <experimental/string_view>
31 # define OIIO_EXPERIMENTAL_STRING_VIEW_AVAILABLE
32 #endif
33 
34 
36 
37 
38 /// A `string_view` is a non-owning, non-copying, non-allocating reference
39 /// to a sequence of characters. It encapsulates both a character pointer
40 /// and a length. This is analogous to C++17 std::string_view, but supports
41 /// C++14.
42 ///
43 /// Note: `string_view` is an alias for `basic_string_view<char>`.
44 ///
45 /// A function that takes a string input (but does not need to alter the
46 /// string in place) may use a string_view parameter and accept input that
47 /// is any of char* (C string), string literal (constant char array), a
48 /// std::string (C++ string), or OIIO ustring. For all of these cases, no
49 /// extra allocations are performed, and no extra copies of the string
50 /// contents are performed (as they would be, for example, if the function
51 /// took a const std::string& argument but was passed a char* or string
52 /// literal).
53 ///
54 /// Furthermore, a function that returns a copy or a substring of one of its
55 /// inputs (for example, a substr()-like function) may return a string_view
56 /// rather than a std::string, and thus generate its return value without
57 /// any allocation or copying. Upon assignment to a std::string or ustring,
58 /// it will properly auto-convert.
59 ///
60 /// There are two important caveats to using this class:
61 /// 1. The string_view merely refers to characters owned by another string,
62 /// so the string_view may not be used outside the lifetime of the string
63 /// it refers to. Thus, string_view is great for parameter passing, but
64 /// it's not a good idea to use a string_view to store strings in a data
65 /// structure (unless you are really sure you know what you're doing).
66 /// 2. Because the run of characters that the string_view refers to may not
67 /// be 0-terminated, it is important to distinguish between the data()
68 /// method, which returns the pointer to the characters, and a proper
69 /// c_str() method (which is NOT provided by std::string_view), which would
70 /// be guaranteed to return a valid C string that is 0-terminated. Thus, if
71 /// you want to pass the contents of a string_view to a function that
72 /// expects a 0-terminated string (say, fopen), the usual practice is to
73 /// call `fopen(std::string(my_string_view).c_str())`.
74 ///
75 
76 
77 template<class CharT, class Traits = std::char_traits<CharT>>
78 class basic_string_view {
79 public:
80  using charT = CharT; // DEPRECATED(2.4)
81  using traits_type = Traits;
82  using value_type = CharT;
83  using pointer = const CharT*;
84  using const_pointer = const CharT*;
85  using reference = const CharT&;
86  using const_reference = const CharT&;
89  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
91  using size_type = size_t;
92  using difference_type = ptrdiff_t;
93  using traits = std::char_traits<CharT>; // obsolete custom name
95  static const size_type npos = ~size_type(0);
96 
97  /// Default ctr
98  constexpr basic_string_view() noexcept : m_chars(nullptr), m_len(0) { }
99 
100  /// Copy ctr
102  : m_chars(copy.data()), m_len(copy.size()) { }
103 
104  /// Construct from char* and length.
105  constexpr basic_string_view(const CharT* chars, size_t len) noexcept
106  : m_chars(chars), m_len(len) { }
107 
108  /// Construct from char*, use strlen to determine length.
109  constexpr basic_string_view(const CharT* chars) noexcept
110  : m_chars(chars), m_len(chars ? cestrlen(chars) : 0) { }
111 
112  /// Construct from std::string. Remember that a string_view doesn't have
113  /// its own copy of the characters, so don't use the `string_view` after
114  /// the original string has been destroyed or altered.
115  basic_string_view(const string& str) noexcept
116  : m_chars(str.data()), m_len(str.size()) { }
117  // N.B. std::string::size() is constexpr starting with C++20.
118 
119 #if defined(OIIO_STD_STRING_VIEW_AVAILABLE) || defined(OIIO_DOXYGEN)
120  // Construct from a std::string_view.
121  constexpr basic_string_view(const std::basic_string_view<CharT, Traits>& sv) noexcept
122  : m_chars(sv.data()), m_len(sv.size()) { }
123 #endif
124 
125 #ifdef OIIO_EXPERIMENTAL_STRING_VIEW_AVAILABLE
126  // Construct from a std::experimental::string_view.
127  constexpr basic_string_view(const std::experimental::basic_string_view<CharT, Traits>& sv) noexcept
128  : m_chars(sv.data()), m_len(sv.size()) { }
129 #endif
130 
131  /// Convert a string_view to a `std::string`. NOTE: the `str()` method is
132  /// not part of the C++17 std::string_view. If strict interchangeability
133  /// with std::string_view is desired, you might prefer the equivalent
134  /// idiom `std::string(sv)`.
135  OIIO_CONSTEXPR20 string str() const
136  {
137  return *this;
138  // return (m_chars ? string(m_chars, m_len) : string());
139  // N.B. std::string ctr from chars+len is constexpr in C++20.
140  }
141 
142  /// Explicitly request a 0-terminated string. USUALLY, this turns out to
143  /// be just data(), with no significant added expense (because most uses
144  /// of string_view are simple wrappers of C strings, C++ std::string, or
145  /// ustring -- all of which are 0-terminated). But in the more rare case
146  /// that the string_view represents a non-0-terminated substring, it
147  /// will force an allocation and copy underneath.
148  ///
149  /// Caveats:
150  /// 1. This is NOT going to be part of the C++17 std::string_view, so
151  /// it's probably best to avoid this method if you want to have 100%
152  /// drop-in compatibility with std::string_view.
153  /// 2. It is NOT SAFE to use c_str() on a string_view whose last char
154  /// is the end of an allocation -- because that next char may only
155  /// *coincidentally* be a '\0', which will cause c_str() to return
156  /// the string start (thinking it's a valid C string, so why not just
157  /// return its address?), if there's any chance that the subsequent
158  /// char could change from 0 to non-zero during the use of the result
159  /// of c_str(), and thus break the assumption that it's a valid C str.
160  const CharT* c_str() const;
161 
162  // Assignment
164 
165  /// Convert a string_view to a `std::string`.
167  return (m_chars ? string(m_chars, m_len) : std::basic_string<CharT, Traits>());
168  }
169 
170 #if defined(OIIO_STD_STRING_VIEW_AVAILABLE) || defined(OIIO_DOXYGEN)
171  // Convert an OIIO::string_view to a std::string_view.
172  constexpr operator std::basic_string_view<CharT, Traits>() const
173  {
174  return { data(), size() };
175  }
176 #endif
177 
178 #ifdef OIIO_EXPERIMENTAL_STRING_VIEW_AVAILABLE
179  // Convert an OIIO::string_view to a std::experimental::string_view.
180  constexpr operator std::experimental::basic_string_view<CharT, Traits>() const noexcept
181  {
182  return { data(), size() };
183  }
184 #endif
185 
186 #ifdef FMT_VERSION
187  // Convert an OIIO::string_view to a fmt::string_view. This enables
188  // fmt::format() and friends to accept an OIIO::string_view.
189  constexpr operator fmt::string_view() const noexcept { return { data(), size() }; }
190 #endif
191 
192  // iterators
193  constexpr iterator begin() const noexcept { return m_chars; }
194  constexpr iterator end() const noexcept { return m_chars + m_len; }
195  constexpr const_iterator cbegin() const noexcept { return m_chars; }
196  constexpr const_iterator cend() const noexcept { return m_chars + m_len; }
197  OIIO_CONSTEXPR17 reverse_iterator rbegin() const noexcept { return reverse_iterator (end()); }
198  OIIO_CONSTEXPR17 reverse_iterator rend() const noexcept { return reverse_iterator (begin()); }
199  OIIO_CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator (cend()); }
200  OIIO_CONSTEXPR17 const_reverse_iterator crend() const noexcept { return const_reverse_iterator (cbegin()); }
201 
202  // capacity
203  constexpr size_type size() const noexcept { return m_len; }
204  constexpr size_type length() const noexcept { return m_len; }
205  constexpr size_type max_size() const noexcept {
207  }
208  /// Is the basic_string_view empty, containing no characters?
209  constexpr bool empty() const noexcept { return m_len == 0; }
210 
211  /// Element access of an individual character (beware: no bounds
212  /// checking!).
213  constexpr const_reference operator[](size_type pos) const { return m_chars[pos]; }
214  /// Element access with bounds checking and exception if out of bounds.
215  OIIO_CONSTEXPR17 const_reference at(size_t pos) const
216  {
217  if (pos >= m_len)
218  throw(std::out_of_range("OpenImageIO::string_view::at"));
219  return m_chars[pos];
220  }
221  constexpr const_reference front() const { return m_chars[0]; }
222  constexpr const_reference back() const { return m_chars[m_len - 1]; }
223  constexpr const_pointer data() const noexcept { return m_chars; }
224 
225  // modifiers
226  OIIO_CONSTEXPR14 void clear() noexcept { init(nullptr, 0); }
228  {
229  if (n > m_len)
230  n = m_len;
231  m_chars += n;
232  m_len -= n;
233  }
235  {
236  if (n > m_len)
237  n = m_len;
238  m_len -= n;
239  }
240 
242  {
243  if (pos >= size())
244  return basic_string_view(); // start past end -> return empty
245  if (n == npos || pos + n > size())
246  n = size() - pos;
247  return basic_string_view(data() + pos, n);
248  }
249 
250  OIIO_CONSTEXPR17 int compare (basic_string_view x) const noexcept {
251  // N.B. char_traits<char>::compare is constexpr for C++17
252  const int cmp = traits_type::compare (m_chars, x.m_chars, (std::min)(m_len, x.m_len));
253  return cmp != 0 ? cmp : int(m_len) - int(x.m_len);
254  // Equivalent to:
255  // cmp != 0 ? cmp : (m_len == x.m_len ? 0 : (m_len < x.m_len ? -1 : 1));
256  }
257 
258 #if 0
259  // Do these later if anybody needs them
260  bool starts_with(basic_string_view x) const noexcept;
261  bool ends_with(basic_string_view x) const noexcept;
262  size_type copy(CharT* dest, size_type count, size_type pos = 0) const;
263 #endif
264 
265  /// Find the first occurrence of substring s in *this, starting at
266  /// position pos.
267  size_type find(basic_string_view s, size_t pos = 0) const noexcept
268  {
269  if (pos > size())
270  pos = size();
271  const_iterator i = std::search(this->cbegin() + pos, this->cend(),
272  s.cbegin(), s.cend(), traits::eq);
273  return i == this->cend() ? npos : std::distance(this->cbegin(), i);
274  }
275 
276  /// Find the first occurrence of character c in *this, starting at
277  /// position pos.
278  size_type find (CharT c, size_t pos=0) const noexcept {
279  if (pos > size())
280  pos = size();
281  const_iterator i = std::find_if (this->cbegin()+pos, this->cend(),
282  traits_eq(c));
283  return i == this->cend() ? npos : std::distance (this->cbegin(), i);
284  }
285 
286  /// Find the last occurrence of substring s *this, but only those
287  /// occurrences earlier than position pos.
288  size_type rfind (basic_string_view s, size_t pos=npos) const noexcept {
289  if (pos > size())
290  pos = size();
291  const_reverse_iterator b = this->crbegin()+(size()-pos);
292  const_reverse_iterator e = this->crend();
293  const_reverse_iterator i = std::search (b, e, s.crbegin(), s.crend(), traits::eq);
294  return i == e ? npos : (reverse_distance(this->crbegin(),i) - s.size() + 1);
295  }
296 
297  /// Find the last occurrence of character c in *this, but only those
298  /// occurrences earlier than position pos.
299  size_type rfind (CharT c, size_t pos=npos) const noexcept {
300  if (pos > size())
301  pos = size();
302  const_reverse_iterator b = this->crbegin()+(size()-pos);
303  const_reverse_iterator e = this->crend();
304  const_reverse_iterator i = std::find_if (b, e, traits_eq(c));
305  return i == e ? npos : reverse_distance (this->crbegin(),i);
306  }
307 
308  size_type find_first_of (CharT c, size_t pos=0) const noexcept { return find (c, pos); }
309 
310  size_type find_last_of (CharT c, size_t pos=npos) const noexcept { return rfind (c, pos); }
311 
312  size_type find_first_of (basic_string_view s, size_t pos=0) const noexcept {
313  if (pos >= size())
314  return npos;
315  const_iterator i = std::find_first_of (this->cbegin()+pos, this->cend(),
316  s.cbegin(), s.cend(), traits::eq);
317  return i == this->cend() ? npos : std::distance (this->cbegin(), i);
318  }
319 
320  size_type find_last_of (basic_string_view s, size_t pos=npos) const noexcept {
321  if (pos > size())
322  pos = size();
323  size_t off = size()-pos;
324  const_reverse_iterator i = std::find_first_of (this->crbegin()+off, this->crend(),
325  s.cbegin(), s.cend(), traits::eq);
326  return i == this->crend() ? npos : reverse_distance (this->crbegin(), i);
327  }
328 
329  size_type find_first_not_of (basic_string_view s, size_t pos=0) const noexcept {
330  if (pos >= size())
331  return npos;
332  const_iterator i = find_not_of (this->cbegin()+pos, this->cend(), s);
333  return i == this->cend() ? npos : std::distance (this->cbegin(), i);
334  }
335 
336  size_type find_first_not_of (CharT c, size_t pos=0) const noexcept {
337  if (pos >= size())
338  return npos;
339  for (const_iterator i = this->cbegin()+pos; i != this->cend(); ++i)
340  if (! traits::eq (c, *i))
341  return std::distance (this->cbegin(), i);
342  return npos;
343  }
344 
345  size_type find_last_not_of (basic_string_view s, size_t pos=npos) const noexcept {
346  if (pos > size())
347  pos = size();
348  size_t off = size()-pos;
349  const_reverse_iterator i = find_not_of (this->crbegin()+off, this->crend(), s);
350  return i == this->crend() ? npos : reverse_distance (this->crbegin(), i);
351  }
352 
353  size_type find_last_not_of (CharT c, size_t pos=npos) const noexcept {
354  if (pos > size())
355  pos = size();
356  size_t off = size()-pos;
357  for (const_reverse_iterator i = this->crbegin()+off; i != this->crend(); ++i)
358  if (! traits::eq (c, *i))
359  return reverse_distance (this->crbegin(), i);
360  return npos;
361  }
362 
363  friend OIIO_CONSTEXPR17 bool
365  {
366  return x.size() == y.size() ? (x.compare(y) == 0) : false;
367  }
368 
369  friend OIIO_CONSTEXPR17 bool
371  {
372  return x.size() == y.size() ? (x.compare(y) != 0) : true;
373  }
374 
375  friend OIIO_CONSTEXPR17 bool
377  {
378  return x.compare(y) < 0;
379  }
380 
381  friend OIIO_CONSTEXPR17 bool
383  {
384  return x.compare(y) > 0;
385  }
386 
387  friend OIIO_CONSTEXPR17 bool
389  {
390  return x.compare(y) <= 0;
391  }
392 
393  friend OIIO_CONSTEXPR17 bool
395  {
396  return x.compare(y) >= 0;
397  }
398 
399  friend std::basic_ostream<CharT, Traits>&
400  operator<<(std::basic_ostream<CharT, Traits>& out,
401  const basic_string_view& str)
402  {
403  if (out.good())
404  out.write(str.data(), str.size());
405  return out;
406  }
407 
408 private:
409  const CharT* m_chars = nullptr;
410  size_t m_len = 0;
411 
412  OIIO_CONSTEXPR14 void init(const CharT* chars, size_t len) noexcept
413  {
414  m_chars = chars;
415  m_len = len;
416  }
417 
418  template<typename r_iter>
419  size_type reverse_distance(r_iter first, r_iter last) const noexcept
420  {
421  return m_len - 1 - std::distance(first, last);
422  }
423 
424  template<typename iter>
425  iter find_not_of(iter first, iter last, basic_string_view s) const noexcept
426  {
427  for (; first != last; ++first)
428  if (!traits::find(s.data(), s.length(), *first))
429  return first;
430  return last;
431  }
432 
433  // Guaranteed constexpr length of a C string
434  static constexpr size_t cestrlen(const charT* chars) {
435 #if OIIO_CPLUSPLUS_VERSION >= 17
436  return Traits::length(chars);
437 #else
438  if (chars == nullptr)
439  return 0;
440  size_t len = 0;
441  while (chars[len] != 0)
442  len++;
443  return len;
444 #endif
445  }
446 
447  class traits_eq {
448  public:
449  constexpr traits_eq (CharT ch) noexcept : ch(ch) {}
450  constexpr bool operator () (CharT val) const noexcept { return traits::eq (ch, val); }
451  CharT ch;
452  };
453 };
454 
455 
456 
457 /// string_view is an alias for `basic_string_view<char>`. This is the
458 /// common use case.
461 
462 
463 
464 // DEPRECATED name equivalence
465 OIIO_DEPRECATED("Use string_view (2.3)")
467 
468 
469 /// Return a safe pointer to a null-terminated C string with the contents of
470 /// the string_view.
471 ///
472 /// ENORMOUS CAVEAT: This nonstandard functionality is only safe if the
473 /// string_view is a true "subset of a C/C++ string". It will fail in the
474 /// unfortunate case where the last character of `str` is the last byte of a
475 /// readable page of memory and the next character is on a page that's not
476 /// readable. This can never happen to a string_view that was constructed from
477 /// a C string, a C++ std::string, an OIIO ustring, or any subset of
478 /// characters from any of those. But still, watch out if you're constructing
479 /// a string_view a pointer to some other memory region that's not at all part
480 /// of a string-like object.
481 ///
482 /// How do we get a safe c_str from a string_view? It's a neat trick! First,
483 /// we check if `str[str.size()]` is a null character. If it is -- and this is
484 /// the very common case of the string_view being a way to pass a reference to
485 /// an entire std::string, a C string (char*), or a ustring -- then it just
486 /// returns `str.data()`, since that is a totally valid null-terminated C
487 /// string! On the other hand, if `str[str.size()] != 0`, then we construct a
488 /// ustring and return its `ustring::c_str()`, which is safe because ustring
489 /// memory is never freed.
490 OIIO_UTIL_API const char* c_str(string_view str);
491 
492 
493 template<> inline const char*
494 basic_string_view<char>::c_str() const {
495  return OIIO::c_str(*this);
496 }
497 
498 
500 
501 
502 #if FMT_VERSION >= 100000
504 template <> struct formatter<OIIO::string_view> : formatter<string_view>
505 {
506  auto format(OIIO::string_view c, format_context& ctx) const {
508  }
509 };
511 #endif
512 
513 
514 
515 // Declare std::size and std::ssize for our string_view.
516 namespace std {
517 
518 #if OIIO_CPLUSPLUS_VERSION < 17
519 template<class CharT, class Traits = std::char_traits<CharT>>
520 constexpr size_t size(const OIIO::basic_string_view<CharT, Traits>& c) {
521  return c.size();
522 }
523 #endif
524 
525 #if OIIO_CPLUSPLUS_VERSION < 20
526 template<class CharT, class Traits = std::char_traits<CharT>>
527 constexpr ptrdiff_t ssize(const OIIO::basic_string_view<CharT, Traits>& c) {
528  return static_cast<ptrdiff_t>(c.size());
529 }
530 #endif
531 
532 // Allow client software to easily know if the std::size/ssize was added for
533 // our string_view.
534 #define OIIO_STRING_VIEW_HAS_STD_SIZE 1
535 
536 
537 } // namespace std
#define OIIO_CONSTEXPR14
Definition: platform.h:95
GLint first
Definition: glcorearb.h:405
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
constexpr iterator begin() const noexcept
Definition: string_view.h:193
constexpr basic_string_view(const basic_string_view &copy)
Copy ctr.
Definition: string_view.h:101
const_reverse_iterator reverse_iterator
Definition: string_view.h:90
std::char_traits< CharT > traits
Definition: string_view.h:93
constexpr size_t size(const OIIO::span< T, E > &c)
Definition: span.h:381
OIIO_CONSTEXPR17 const_reverse_iterator crend() const noexcept
Definition: string_view.h:200
size_type find_first_not_of(basic_string_view s, size_t pos=0) const noexcept
Definition: string_view.h:329
OIIO_CONSTEXPR14 void clear() noexcept
Definition: string_view.h:226
OIIO_CONSTEXPR14 basic_string_view substr(size_type pos, size_type n=npos) const noexcept
Definition: string_view.h:241
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
constexpr const_iterator cend() const noexcept
Definition: string_view.h:196
CompareResults OIIO_API compare(const ImageBuf &A, const ImageBuf &B, float failthresh, float warnthresh, float failrelative, float warnrelative, ROI roi={}, int nthreads=0)
constexpr basic_string_view(const CharT *chars, size_t len) noexcept
Construct from char* and length.
Definition: string_view.h:105
constexpr const_pointer data() const noexcept
Definition: string_view.h:223
GLdouble s
Definition: glad.h:3009
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:795
bool OIIO_UTIL_API ends_with(string_view a, string_view b)
Does 'a' end with the string 'b', with a case-sensitive comparison?
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
#define OIIO_DEPRECATED(msg)
Definition: platform.h:466
GLint y
Definition: glcorearb.h:103
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
Definition: core.h:2138
constexpr size_type max_size() const noexcept
Definition: string_view.h:205
#define OIIO_UTIL_API
Definition: export.h:71
OIIO_CONSTEXPR17 int compare(basic_string_view x) const noexcept
Definition: string_view.h:250
const CharT & const_reference
Definition: string_view.h:86
#define FMT_END_NAMESPACE
Definition: core.h:179
OIIO_CONSTEXPR14 void remove_suffix(size_type n) noexcept
Definition: string_view.h:234
IMATH_HOSTDEVICE constexpr int cmp(T a, T b) IMATH_NOEXCEPT
Definition: ImathFun.h:84
size_type find_first_of(CharT c, size_t pos=0) const noexcept
Definition: string_view.h:308
constexpr auto end() const noexcept-> iterator
Definition: core.h:446
size_type find_first_of(basic_string_view s, size_t pos=0) const noexcept
Definition: string_view.h:312
constexpr const_reference back() const
Definition: string_view.h:222
GLdouble n
Definition: glcorearb.h:2008
friend OIIO_CONSTEXPR17 bool operator>(basic_string_view x, basic_string_view y) noexcept
Definition: string_view.h:382
constexpr basic_string_view(const CharT *chars) noexcept
Construct from char*, use strlen to determine length.
Definition: string_view.h:109
size_type find(CharT c, size_t pos=0) const noexcept
Definition: string_view.h:278
static const size_type npos
Definition: string_view.h:95
constexpr basic_string_view() noexcept
Default ctr.
Definition: string_view.h:98
constexpr const_reference front() const
Definition: string_view.h:221
OIIO_CONSTEXPR14 basic_string_view & operator=(const basic_string_view &copy) noexcept=default
constexpr const_iterator cbegin() const noexcept
Definition: string_view.h:195
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
constexpr size_type size() const noexcept
Definition: string_view.h:203
const CharT & reference
Definition: string_view.h:85
size_type find_last_of(basic_string_view s, size_t pos=npos) const noexcept
Definition: string_view.h:320
size_type find_first_not_of(CharT c, size_t pos=0) const noexcept
Definition: string_view.h:336
const CharT * c_str() const
size_type find_last_not_of(basic_string_view s, size_t pos=npos) const noexcept
Definition: string_view.h:345
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
OIIO_CONSTEXPR17 reverse_iterator rbegin() const noexcept
Definition: string_view.h:197
GLint GLenum GLint x
Definition: glcorearb.h:409
OIIO_CONSTEXPR17 const_reference at(size_t pos) const
Element access with bounds checking and exception if out of bounds.
Definition: string_view.h:215
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: string_view.h:89
auto search(const T &set, const V &val) -> std::pair< bool, decltype(std::begin(detail::smart_deref(set)))>
A search function.
Definition: CLI11.h:3170
friend OIIO_CONSTEXPR17 bool operator==(basic_string_view x, basic_string_view y) noexcept
Definition: string_view.h:364
constexpr auto size() const noexcept-> size_t
Definition: core.h:443
basic_string_view(const string &str) noexcept
Definition: string_view.h:115
__hostdev__ uint64_t last(uint32_t i) const
Definition: NanoVDB.h:5976
GLsizeiptr size
Definition: glcorearb.h:664
OIIO_CONSTEXPR17 reverse_iterator rend() const noexcept
Definition: string_view.h:198
OIIO_CONSTEXPR17 const_reverse_iterator crbegin() const noexcept
Definition: string_view.h:199
OIIO_CONSTEXPR20 string str() const
Definition: string_view.h:135
friend OIIO_CONSTEXPR17 bool operator>=(basic_string_view x, basic_string_view y) noexcept
Definition: string_view.h:394
size_type find_last_of(CharT c, size_t pos=npos) const noexcept
Definition: string_view.h:310
size_type rfind(CharT c, size_t pos=npos) const noexcept
Definition: string_view.h:299
FMT_CONSTEXPR_CHAR_TRAITS bool starts_with(basic_string_view< Char > sv) const noexcept
Definition: core.h:457
constexpr const_reference operator[](size_type pos) const
Definition: string_view.h:213
const_pointer const_iterator
Definition: string_view.h:87
GLuint GLfloat * val
Definition: glcorearb.h:1608
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
basic_string_view< char > string_view
Definition: string_view.h:459
const char * iterator
Definition: core.h:405
constexpr auto data() const noexcept-> const Char *
Definition: core.h:440
constexpr iterator end() const noexcept
Definition: string_view.h:194
OIIO_UTIL_API const char * c_str(string_view str)
friend auto operator<=(basic_string_view lhs, basic_string_view rhs) -> bool
Definition: core.h:489
OIIO_CONSTEXPR14 void remove_prefix(size_type n) noexcept
Definition: string_view.h:227
const CharT * const_pointer
Definition: string_view.h:84
constexpr auto begin() const noexcept-> iterator
Definition: core.h:445
#define FMT_BEGIN_NAMESPACE
Definition: core.h:176
constexpr ptrdiff_t ssize(const OIIO::span< T, E > &c)
Definition: span.h:394
#define OIIO_NAMESPACE_END
Definition: oiioversion.h:127
SIM_API const UT_StringHolder distance
constexpr bool empty() const noexcept
Is the basic_string_view empty, containing no characters?
Definition: string_view.h:209
size_type find_last_not_of(CharT c, size_t pos=npos) const noexcept
Definition: string_view.h:353
size_type find(basic_string_view s, size_t pos=0) const noexcept
Definition: string_view.h:267
friend OIIO_CONSTEXPR17 bool operator!=(basic_string_view x, basic_string_view y) noexcept
Definition: string_view.h:370
size_type rfind(basic_string_view s, size_t pos=npos) const noexcept
Definition: string_view.h:288
GLint GLsizei count
Definition: glcorearb.h:405
constexpr size_type length() const noexcept
Definition: string_view.h:204
Definition: format.h:1821
friend auto operator<(basic_string_view lhs, basic_string_view rhs) -> bool
Definition: core.h:486
#define OIIO_NAMESPACE_BEGIN
Definition: oiioversion.h:126