Small improvements for StringRef

* `operator[]` is constexpr
* `operator<<` and `operator+=` are hidden friends
This commit is contained in:
Martin Hořeňovský 2020-05-10 07:22:11 +02:00
parent 094d840efe
commit 895d0a0696
No known key found for this signature in database
GPG key ID: DE48307B8B0D381A
8 changed files with 20 additions and 12 deletions

View file

@ -126,8 +126,6 @@ TEST_CASE( "StringRef", "[Strings][StringRef]" ) {
}
TEST_CASE("StringRef at compilation time", "[Strings][StringRef][constexpr]") {
//TODO:
// * substr
using Catch::StringRef;
SECTION("Simple constructors") {
constexpr StringRef empty{};
@ -144,6 +142,7 @@ TEST_CASE("StringRef at compilation time", "[Strings][StringRef][constexpr]") {
STATIC_REQUIRE(stringref.begin() != stringref.end());
STATIC_REQUIRE(stringref.substr(10, 0).empty());
STATIC_REQUIRE(stringref.substr(2, 1).data() == abc + 2);
STATIC_REQUIRE(stringref[1] == 'b');
constexpr StringRef shortened(abc, 2);