MCPcopy Create free account
hub / github.com/RenderKit/embree / StringRef

Class StringRef

tutorials/external/catch.hpp:520–609  ·  view source on GitHub ↗

A non-owning string class (similar to the forthcoming std::string_view) Note that, because a StringRef may be a substring of another string, it may not be null terminated. c_str() must return a null terminated string, however, and so the StringRef will internally take ownership (taking a copy), if necessary. In theory this ownership is not externally visible - but it does mean (substring) StringRe

Source from the content-addressed store, hash-verified

518 /// visible - but it does mean (substring) StringRefs should not be shared between
519 /// threads.
520 class StringRef {
521 public:
522 using size_type = std::size_t;
523
524 private:
525 friend struct StringRefTestAccess;
526
527 char const* m_start;
528 size_type m_size;
529
530 char* m_data = nullptr;
531
532 void takeOwnership();
533
534 static constexpr char const* const s_empty = "";
535
536 public: // construction/ assignment
537 StringRef() noexcept
538 : StringRef( s_empty, 0 )
539 {}
540
541 StringRef( StringRef const& other ) noexcept
542 : m_start( other.m_start ),
543 m_size( other.m_size )
544 {}
545
546 StringRef( StringRef&& other ) noexcept
547 : m_start( other.m_start ),
548 m_size( other.m_size ),
549 m_data( other.m_data )
550 {
551 other.m_data = nullptr;
552 }
553
554 StringRef( char const* rawChars ) noexcept;
555
556 StringRef( char const* rawChars, size_type size ) noexcept
557 : m_start( rawChars ),
558 m_size( size )
559 {}
560
561 StringRef( std::string const& stdString ) noexcept
562 : m_start( stdString.c_str() ),
563 m_size( stdString.size() )
564 {}
565
566 ~StringRef() noexcept {
567 delete[] m_data;
568 }
569
570 auto operator = ( StringRef const &other ) noexcept -> StringRef& {
571 delete[] m_data;
572 m_data = nullptr;
573 m_start = other.m_start;
574 m_size = other.m_size;
575 return *this;
576 }
577

Callers 8

operator "" _srFunction · 0.85
operator "" _catch_srFunction · 0.85
NameAndTagsClass · 0.85
RunContextMethod · 0.85
resetAssertionInfoMethod · 0.85
runCurrentTestMethod · 0.85
substrMethod · 0.85
TablePrinterClass · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected