Changes
Page history
Update cpp
authored
Mar 19, 2024
by
umaumax
Show whitespace changes
Inline
Side-by-side
cpp.md
View page @
9925537b
...
@@ -1911,6 +1911,7 @@ bool IsFileExist(const std::string &filename) {
...
@@ -1911,6 +1911,7 @@ bool IsFileExist(const std::string &filename) {
#include
<iterator>
#include
<iterator>
#include
<vector>
#include
<vector>
// LoadFileGood_istreambuf_iteratorと比較して、2倍ほど遅い
std
::
vector
<
uint8_t
>
LoadFileGood
(
const
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
())
{
...
@@ -1930,6 +1931,7 @@ std::vector<uint8_t> LoadFileGood(const std::string& filepath) {
...
@@ -1930,6 +1931,7 @@ std::vector<uint8_t> LoadFileGood(const std::string& filepath) {
return
vec
;
return
vec
;
}
}
// 🌟おすすめ
std
::
vector
<
uint8_t
>
LoadFileGood_istreambuf_iterator
(
const
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
;
...
...
...
...