Skip to content

Commit fafe2ca

Browse files
author
MarcoFalke
committed
refactor: Remove redundant file check from AutoFile shift operators
The shift operators will call the write or read member function, which already does the check. Also, call sites are free to directly call ::(Un)Serialize(s, obj) to skip this check, so removing it increases consistency.
1 parent 9999a49 commit fafe2ca

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

src/streams.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -560,15 +560,13 @@ class AutoFile
560560
template <typename T>
561561
AutoFile& operator<<(const T& obj)
562562
{
563-
if (!file) throw std::ios_base::failure("AutoFile::operator<<: file handle is nullptr");
564563
::Serialize(*this, obj);
565564
return *this;
566565
}
567566

568567
template <typename T>
569568
AutoFile& operator>>(T&& obj)
570569
{
571-
if (!file) throw std::ios_base::failure("AutoFile::operator>>: file handle is nullptr");
572570
::Unserialize(*this, obj);
573571
return *this;
574572
}
@@ -588,19 +586,13 @@ class CAutoFile : public AutoFile
588586
template<typename T>
589587
CAutoFile& operator<<(const T& obj)
590588
{
591-
// Serialize to this stream
592-
if (!file)
593-
throw std::ios_base::failure("CAutoFile::operator<<: file handle is nullptr");
594589
::Serialize(*this, obj);
595590
return (*this);
596591
}
597592

598593
template<typename T>
599594
CAutoFile& operator>>(T&& obj)
600595
{
601-
// Unserialize from this stream
602-
if (!file)
603-
throw std::ios_base::failure("CAutoFile::operator>>: file handle is nullptr");
604596
::Unserialize(*this, obj);
605597
return (*this);
606598
}

0 commit comments

Comments
 (0)