Changes
Page history
Update cpp
authored
Mar 19, 2024
by
umaumax
Show whitespace changes
Inline
Side-by-side
cpp.md
View page @
332b4c6e
...
@@ -1911,7 +1911,7 @@ bool IsFileExist(const std::string &filename) {
...
@@ -1911,7 +1911,7 @@ bool IsFileExist(const std::string &filename) {
#include
<iterator>
#include
<iterator>
#include
<vector>
#include
<vector>
std
::
vector
<
uint8_t
>
LoadFileGood
(
std
::
string
&
filepath
)
{
std
::
vector
<
uint8_t
>
LoadFileGood
(
const
std
::
string
&
filepath
)
{
std
::
ifstream
file
(
filepath
,
std
::
ios
::
binary
);
std
::
ifstream
file
(
filepath
,
std
::
ios
::
binary
);
if
(
file
.
fail
())
{
if
(
file
.
fail
())
{
return
std
::
vector
<
uint8_t
>
();
return
std
::
vector
<
uint8_t
>
();
...
@@ -1930,14 +1930,14 @@ std::vector<uint8_t> LoadFileGood(std::string& filepath) {
...
@@ -1930,14 +1930,14 @@ std::vector<uint8_t> LoadFileGood(std::string& filepath) {
return
vec
;
return
vec
;
}
}
std
::
vector
<
uint8_t
>
LoadFileGood_istreambuf_iterator
(
std
::
string
&
filepath
)
{
std
::
vector
<
uint8_t
>
LoadFileGood_istreambuf_iterator
(
const
std
::
string
&
filepath
)
{
std
::
ifstream
is
(
filepath
,
std
::
ios
::
in
|
std
::
ios
::
binary
);
std
::
ifstream
is
(
filepath
,
std
::
ios
::
in
|
std
::
ios
::
binary
);
std
::
istreambuf_iterator
<
char
>
start
(
is
),
end
;
std
::
istreambuf_iterator
<
char
>
start
(
is
),
end
;
std
::
vector
<
uint8_t
>
content
(
start
,
end
);
std
::
vector
<
uint8_t
>
content
(
start
,
end
);
return
content
;
return
content
;
}
}
std
::
vector
<
uint8_t
>
LoadFileBad_istream_iterator
(
std
::
string
&
filepath
)
{
std
::
vector
<
uint8_t
>
LoadFileBad_istream_iterator
(
const
std
::
string
&
filepath
)
{
std
::
ifstream
is
(
filepath
,
std
::
ios
::
in
|
std
::
ios
::
binary
);
std
::
ifstream
is
(
filepath
,
std
::
ios
::
in
|
std
::
ios
::
binary
);
std
::
istream_iterator
<
char
>
start
(
is
),
end
;
std
::
istream_iterator
<
char
>
start
(
is
),
end
;
std
::
vector
<
uint8_t
>
content
(
start
,
end
);
std
::
vector
<
uint8_t
>
content
(
start
,
end
);
...
...
...
...