mirror of
https://github.com/catchorg/Catch2.git
synced 2025-11-18 19:49:33 +01:00
Removed templated StringRef ctor and added StringRef literal
This commit is contained in:
@@ -23,10 +23,12 @@ namespace Catch {
|
||||
/// visible - but it does mean (substring) StringRefs should not be shared between
|
||||
/// threads.
|
||||
class StringRef {
|
||||
public:
|
||||
using size_type = std::size_t;
|
||||
|
||||
private:
|
||||
friend struct StringRefTestAccess;
|
||||
|
||||
using size_type = std::size_t;
|
||||
|
||||
char const* m_start;
|
||||
size_type m_size;
|
||||
|
||||
@@ -54,11 +56,7 @@ namespace Catch {
|
||||
other.m_data = nullptr;
|
||||
}
|
||||
|
||||
template<size_t Size>
|
||||
StringRef( char const(& rawChars)[Size] ) noexcept
|
||||
: m_start( rawChars ),
|
||||
m_size( static_cast<size_type>( Size-1 ) )
|
||||
{}
|
||||
StringRef( char const* rawChars ) noexcept;
|
||||
|
||||
StringRef( char const* rawChars, size_type size ) noexcept
|
||||
: m_start( rawChars ),
|
||||
@@ -82,8 +80,6 @@ namespace Catch {
|
||||
return *this;
|
||||
}
|
||||
|
||||
static auto fromRaw( char const *rawChars ) -> StringRef;
|
||||
|
||||
operator std::string() const;
|
||||
|
||||
void swap( StringRef& other ) noexcept;
|
||||
@@ -120,6 +116,10 @@ namespace Catch {
|
||||
|
||||
auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&;
|
||||
|
||||
inline auto operator ""_sr( char const* rawChars, std::size_t size ) noexcept -> StringRef {
|
||||
return StringRef( rawChars, size );
|
||||
}
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
#endif // CATCH_STRINGREF_H_INCLUDED
|
||||
|
||||
Reference in New Issue
Block a user