Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Align path_view::render_* APIs with P1036R6 #140

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions example/path_view_openat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace path_view_openat_example
if(base != nullptr || is_ntpath)
{
// The NT kernel always takes the system wide encoding
auto zpath = path.render_unterminated<wchar_t>(path);
auto zpath = path.render_unterminated<wchar_t>();
UNICODE_STRING _path{};
_path.Buffer = const_cast<wchar_t *>(zpath.data());
_path.MaximumLength =
Expand Down Expand Up @@ -109,14 +109,14 @@ namespace path_view_openat_example
if constexpr(is_same_v<type, char>)
{
// Render to the system narrow encoding null terminated
auto zpath = path.render_null_terminated<char>(path);
auto zpath = path.render_null_terminated<char>();
return CreateFileA(zpath.c_str(), access, share, nullptr, creation,
flags, nullptr);
}
else // char8_t, char16_t, wchar_t
{
// Render to the system wide encoding null terminated
auto zpath = path.render_null_terminated<wchar_t>(path);
auto zpath = path.render_null_terminated<wchar_t>();
return CreateFileW(zpath.c_str(), access, share, nullptr, creation,
flags, nullptr);
}
Expand Down
10 changes: 4 additions & 6 deletions include/llfio/v2.0/path_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1563,21 +1563,19 @@ class LLFIO_DECL path_view_component
LLFIO_TREQUIRES(LLFIO_TPRED(is_source_acceptable<T>),
Copy link

Choose a reason for hiding this comment

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

render(), immediately above this, was removed in P1036R6. Consistency dictates that either it should go away or also remove the first argument.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, I missed the history entries

  • R5: render() function added as per LEWG request
  • R6: render() function removed as per LEWG request

🙃

However, given that render() has existed for almost two years, I would first deprecate it for one "release" and then remove it. That should ease the transition for our user base considerably at a very low cost.

Copy link
Owner

Choose a reason for hiding this comment

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

I think the number of users of those functions is likely very low, as they were only added by LEWG and as you correctly point out, were clearly added wrong by me likely very late at night when my eyes weren't working.

P1030R7 is nearing completion after a month of working on it, so I'm going to go ahead and merge this. Thanks for the changeset.

LLFIO_TEXPR(std::is_constructible<rendered_path<zero_termination::zero_terminated, T, AllocatorOrDeleter, _internal_buffer_size>,
path_view_component, Args...>::value))
rendered_path<zero_termination::zero_terminated, T, AllocatorOrDeleter, _internal_buffer_size> render_null_terminated(path_view_component view,
Args &&...args) const
rendered_path<zero_termination::zero_terminated, T, AllocatorOrDeleter, _internal_buffer_size> render_null_terminated(Args &&...args) const
{
return rendered_path<zero_termination::zero_terminated, T, AllocatorOrDeleter, _internal_buffer_size>(view, std::forward<Args>(args)...);
return rendered_path<zero_termination::zero_terminated, T, AllocatorOrDeleter, _internal_buffer_size>(*this, std::forward<Args>(args)...);
}
//! Convenience function
LLFIO_TEMPLATE(class T = typename filesystem::path::value_type, class AllocatorOrDeleter = default_rendered_path_deleter<T[]>,
size_t _internal_buffer_size = default_internal_buffer_size, class... Args)
LLFIO_TREQUIRES(LLFIO_TPRED(is_source_acceptable<T>),
LLFIO_TEXPR(std::is_constructible<rendered_path<zero_termination::zero_terminated, T, AllocatorOrDeleter, _internal_buffer_size>,
path_view_component, Args...>::value))
rendered_path<zero_termination::not_zero_terminated, T, AllocatorOrDeleter, _internal_buffer_size> render_unterminated(path_view_component view,
Args &&...args) const
rendered_path<zero_termination::not_zero_terminated, T, AllocatorOrDeleter, _internal_buffer_size> render_unterminated(Args &&...args) const
{
return rendered_path<zero_termination::not_zero_terminated, T, AllocatorOrDeleter, _internal_buffer_size>(view, std::forward<Args>(args)...);
return rendered_path<zero_termination::not_zero_terminated, T, AllocatorOrDeleter, _internal_buffer_size>(*this, std::forward<Args>(args)...);
}

#ifdef __cpp_concepts
Expand Down
Loading