Skip to content

Commit 9300814

Browse files
committed
const slice in file api
1 parent 9b08c41 commit 9300814

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

rpp/files.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using Alloc = Mallocator<"File IO">;
1010
using File_Time = u64;
1111

1212
[[nodiscard]] Opt<Vec<u8, Alloc>> read(String_View path) noexcept;
13-
[[nodiscard]] bool write(String_View path, Slice<u8> data) noexcept;
13+
[[nodiscard]] bool write(String_View path, Slice<const u8> data) noexcept;
1414

1515
[[nodiscard]] Opt<File_Time> last_write_time(String_View path) noexcept;
1616

rpp/slice.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ struct Slice {
118118
return Slice{data_ + start, length};
119119
}
120120

121-
[[nodiscard]] Slice<u8> to_bytes() noexcept {
121+
[[nodiscard]] Slice<u8> to_bytes() noexcept
122+
requires(!Const<T>)
123+
{
122124
Slice<u8> ret;
123125
ret.data_ = launder(reinterpret_cast<u8*>(data_));
124126
ret.length_ = length_ * sizeof(T);

rpp/w32/files_w32.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace rpp::Files {
7272
return Opt{rpp::move(data)};
7373
}
7474

75-
[[nodiscard]] bool write(String_View path, Slice<u8> data) noexcept {
75+
[[nodiscard]] bool write(String_View path, Slice<const u8> data) noexcept {
7676

7777
auto [ucs2_path, ucs2_path_len] = utf8_to_ucs2(path);
7878
if(ucs2_path_len == 0) {

0 commit comments

Comments
 (0)