Skip to content

Commit ca00325

Browse files
committed
refactor: use std=20
- Use string_view
1 parent e355a00 commit ca00325

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

include/Greet/Foo.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef FOO_H
1010
#define FOO_H
1111

12-
#include <string>
12+
#include <string_view>
1313

1414
namespace Greet
1515
{
@@ -27,11 +27,11 @@ class Foo
2727

2828
void setPlatform();
2929

30-
std::string getPlatform() const;
30+
std::string_view getPlatform() const;
3131

3232
private:
33-
int m_value {};
34-
std::string m_platform;
33+
int m_value {};
34+
std::string_view m_platform;
3535
};
3636

3737
} // namespace Greet

src/Greet/Foo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Foo::greetFromPlatform() const
2929
fmt::print("Hello foo: {} from {}\n", m_value, getPlatform());
3030
}
3131

32-
std::string
32+
std::string_view
3333
Foo::getPlatform() const
3434
{
3535
return m_platform;

test/Foo/test.Foo.c++

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ TEST_CASE("test the execution of foo in OSX", "[foo]")
2121
const auto foo = std::make_unique<Foo>(42);
2222

2323
foo->greetFromPlatform();
24-
auto platform = foo->getPlatform();
24+
const auto platform = foo->getPlatform();
2525

2626
fmt::print("Foo in {}\n", platform);
2727

0 commit comments

Comments
 (0)