diff options
| author | Chris Thrasher | 2025-09-21 18:05:21 -0600 |
|---|---|---|
| committer | Chris Thrasher | 2025-09-22 11:50:44 -0600 |
| commit | 8efee9b7632e6dd014b5b041ee326eef7d0b09e6 (patch) | |
| tree | fbc1657a5d7d414fbe93a412990bcf5cfb2df438 /src/catch2/internal/catch_enum_values_registry.cpp | |
| parent | a5735af2f7d956600250541d289c552ace7e87ae (diff) | |
| download | catch3-devel-c++17.tar.gz | |
Use std::string_viewdevel-c++17
Diffstat (limited to 'src/catch2/internal/catch_enum_values_registry.cpp')
| -rw-r--r-- | src/catch2/internal/catch_enum_values_registry.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/catch2/internal/catch_enum_values_registry.cpp b/src/catch2/internal/catch_enum_values_registry.cpp index a94b6088..a0eeee46 100644 --- a/src/catch2/internal/catch_enum_values_registry.cpp +++ b/src/catch2/internal/catch_enum_values_registry.cpp @@ -19,7 +19,7 @@ namespace Catch { namespace { // Extracts the actual name part of an enum instance // In other words, it returns the Blue part of Bikeshed::Colour::Blue - StringRef extractInstanceName(StringRef enumInstance) { + std::string_view extractInstanceName(std::string_view enumInstance) { // Find last occurrence of ":" size_t name_start = enumInstance.size(); while (name_start > 0 && enumInstance[name_start - 1] != ':') { @@ -29,9 +29,9 @@ namespace Catch { } } - std::vector<StringRef> parseEnums( StringRef enums ) { + std::vector<std::string_view> parseEnums( std::string_view enums ) { auto enumValues = splitStringRef( enums, ',' ); - std::vector<StringRef> parsed; + std::vector<std::string_view> parsed; parsed.reserve( enumValues.size() ); for( auto const& enumValue : enumValues ) { parsed.push_back(trim(extractInstanceName(enumValue))); @@ -41,15 +41,15 @@ namespace Catch { EnumInfo::~EnumInfo() = default; - StringRef EnumInfo::lookup( int value ) const { + std::string_view EnumInfo::lookup( int value ) const { for( auto const& valueToName : m_values ) { if( valueToName.first == value ) return valueToName.second; } - return "{** unexpected enum value **}"_sr; + return "{** unexpected enum value **}"; } - Catch::Detail::unique_ptr<EnumInfo> makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector<int> const& values ) { + Catch::Detail::unique_ptr<EnumInfo> makeEnumInfo( std::string_view enumName, std::string_view allValueNames, std::vector<int> const& values ) { auto enumInfo = Catch::Detail::make_unique<EnumInfo>(); enumInfo->m_name = enumName; enumInfo->m_values.reserve( values.size() ); @@ -63,11 +63,10 @@ namespace Catch { return enumInfo; } - EnumInfo const& EnumValuesRegistry::registerEnum( StringRef enumName, StringRef allValueNames, std::vector<int> const& values ) { + EnumInfo const& EnumValuesRegistry::registerEnum( std::string_view enumName, std::string_view allValueNames, std::vector<int> const& values ) { m_enumInfos.push_back(makeEnumInfo(enumName, allValueNames, values)); return *m_enumInfos.back(); } } // Detail } // Catch - |