Skip to content

Commit 506e289

Browse files
authored
Deprecate path::operator-> (#57)
1 parent 73e9aa4 commit 506e289

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

include/tmp/path

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public:
2121

2222
/// Dereferences the managed path
2323
/// @returns A pointer to the path owned by *this
24-
const std::filesystem::path* operator->() const noexcept;
24+
[[deprecated]] const std::filesystem::path* operator->() const noexcept;
2525

2626
/// Releases the ownership of the managed path;
2727
/// the destructor will not delete the managed path after the call

src/tmp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void create_parent(const fs::path& path) {
3838
/// Deletes the given path recursively, ignoring any errors
3939
/// @param path The path to remove recursively
4040
void remove(const path& path) noexcept {
41-
if (!path->empty()) {
41+
if (!static_cast<const fs::path&>(path).empty()) {
4242
std::error_code ec;
4343
fs::remove_all(path, ec);
4444
}

tests/directory.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace fs = std::filesystem;
1010
/// Tests directory creation with prefix
1111
TEST(directory, create_with_prefix) {
1212
directory tmpdir = directory(PREFIX);
13-
fs::path parent = tmpdir->parent_path();
13+
fs::path parent = tmpdir.path().parent_path();
1414

1515
EXPECT_TRUE(fs::exists(tmpdir));
1616
EXPECT_TRUE(fs::is_directory(tmpdir));
@@ -20,7 +20,7 @@ TEST(directory, create_with_prefix) {
2020
/// Tests directory creation without prefix
2121
TEST(directory, create_without_prefix) {
2222
directory tmpdir = directory();
23-
fs::path parent = tmpdir->parent_path();
23+
fs::path parent = tmpdir.path().parent_path();
2424

2525
EXPECT_TRUE(fs::exists(tmpdir));
2626
EXPECT_TRUE(fs::is_directory(tmpdir));
@@ -82,7 +82,7 @@ TEST(directory, move_constructor) {
8282
directory fst = directory(PREFIX);
8383
directory snd = std::move(fst);
8484

85-
EXPECT_TRUE(fst->empty());
85+
EXPECT_TRUE(fst.path().empty());
8686
EXPECT_TRUE(fs::exists(snd));
8787
}
8888

tests/file.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace fs = std::filesystem;
1010
/// Tests file creation with prefix
1111
TEST(file, create_with_prefix) {
1212
file tmpfile = file(PREFIX);
13-
fs::path parent = tmpfile->parent_path();
13+
fs::path parent = tmpfile.path().parent_path();
1414

1515
EXPECT_TRUE(fs::exists(tmpfile));
1616
EXPECT_TRUE(fs::is_regular_file(tmpfile));
@@ -20,7 +20,7 @@ TEST(file, create_with_prefix) {
2020
/// Tests file creation without prefix
2121
TEST(file, create_without_prefix) {
2222
file tmpfile = file();
23-
fs::path parent = tmpfile->parent_path();
23+
fs::path parent = tmpfile.path().parent_path();
2424

2525
EXPECT_TRUE(fs::exists(tmpfile));
2626
EXPECT_TRUE(fs::is_regular_file(tmpfile));
@@ -33,7 +33,7 @@ TEST(file, create_with_suffix) {
3333

3434
EXPECT_TRUE(fs::exists(tmpfile));
3535
EXPECT_TRUE(fs::is_regular_file(tmpfile));
36-
EXPECT_EQ(tmpfile->extension(), ".test");
36+
EXPECT_EQ(tmpfile.path().extension(), ".test");
3737
}
3838

3939
/// Tests multiple file creation with the same prefix

0 commit comments

Comments
 (0)