Skip to content

Implement LWG-3070 - #923

Merged
Casey Carter (CaseyCarter) merged 2 commits into
microsoft:masterfrom
DailyShana:lwg-3070
Jul 2, 2020
Merged

Casey Carter (CaseyCarter) merged 2 commits into
microsoft:masterfrom
DailyShana:lwg-3070

Conversation

@DailyShana

Copy link
Copy Markdown
Contributor

fix #333

@DailyShana
DailyShana requested a review from a team as a code owner June 26, 2020 11:40
@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added the LWG Library Working Group issue label Jun 27, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing this LWG issue resolution and adding test coverage! Looks good to me. I have an optional suggestion.

Comment thread stl/inc/filesystem Outdated
@DailyShana

Copy link
Copy Markdown
Contributor Author

trying to use std::any_of in the extracted function but cannot pass tests

bool _Relative_path_contains_root_name(const path& _Path) {
    return _STD any_of(_Path.relative_path().begin(), _Path.relative_path().end(),
        [] (const path& _File_name) { return !_Parse_root_name(_File_name.native()).empty(); });
}

out put:

xstring(1988) : Assertion failed: string iterators in range are from different containers

or

Test step failed unexpectedly.
Command: "***\STL\out\build\x64\tests\std\tests\P0218R1_filesystem\05\P0218R1_filesystem.exe"
Exit Code: 3221226505

@BillyONeal

Copy link
Copy Markdown
Member

DailyShana That's because you are calling relative_path() more than once; each call is creating a temporary path. Ideally this shouldn't need to call relative_path at all; it should use the underlying parsing machinery to avoid separate memory allocations here.

Comment thread stl/inc/filesystem
@DailyShana

Copy link
Copy Markdown
Contributor Author

DailyShana That's because you are calling relative_path() more than once; each call is creating a temporary path. Ideally this shouldn't need to call relative_path at all; it should use the underlying parsing machinery to avoid separate memory allocations here.

I see, I didn't notice the effect of calling relative_path(), and I tried using parsing machinery and found loop relative_path is more clear and simple but I didn't notice the memory allocations.

@CaseyCarter Casey Carter (CaseyCarter) changed the title filesystem: implement LWG-3070 Implement LWG-3070 Jul 2, 2020
@CaseyCarter
Casey Carter (CaseyCarter) merged commit 3d7fa78 into microsoft:master Jul 2, 2020
@CaseyCarter

Copy link
Copy Markdown
Contributor

Congratulations on your first contribution to the STL!

@DailyShana
DailyShana deleted the lwg-3070 branch July 2, 2020 14:33
@CaseyCarter Casey Carter (CaseyCarter) removed their assignment Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LWG Library Working Group issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LWG-3070 path::lexically_relative causes surprising results if a filename can also be a root-name

4 participants