Skip to content

Commit

Permalink
Merge pull request #140 from ned14/dev/139_render_this
Browse files Browse the repository at this point in the history
feat!: Align `path_view::render_*` APIs with P1036R6
  • Loading branch information
ned14 authored Aug 29, 2024
2 parents 95a1816 + 6078da5 commit 2ff292f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
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>),
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

0 comments on commit 2ff292f

Please sign in to comment.