Skip to content

Commit f1977d0

Browse files
refactor: remove unused ifstream from buffered file iterator
1 parent 6b20def commit f1977d0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

include/rusty_iterators/file_iterator.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ class FileIterator<FIterType::Buffered>
2828
: public IterInterface<std::string, FileIterator<FIterType::Buffered>>
2929
{
3030
public:
31-
explicit FileIterator(const std::string& filePath) : is(filePath)
31+
explicit FileIterator(const std::string& filePath)
3232
{
33+
std::ifstream is{filePath};
34+
3335
if (!is.is_open())
3436
{
3537
throw std::runtime_error{"Could not open the file."};
@@ -62,7 +64,6 @@ class FileIterator<FIterType::Buffered>
6264

6365
private:
6466
size_t ptr = 0;
65-
std::ifstream is;
6667
std::vector<std::string> fileLines{};
6768
};
6869

0 commit comments

Comments
 (0)