From 8fc9a7e56b9f5f46868e1c44f1e59359574af9c2 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 6 Dec 2023 15:25:48 +0100 Subject: [PATCH] stream: allow invalid handle detection in cached_file Otherwise one cannot distinguish between file open but in failed state and file not open. Signed-off-by: Simon Rozman --- include/stdex/stream.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/stdex/stream.hpp b/include/stdex/stream.hpp index 4fe6f8c10..ae7d176d0 100644 --- a/include/stdex/stream.hpp +++ b/include/stdex/stream.hpp @@ -3167,6 +3167,11 @@ namespace stdex open(filename.c_str(), mode); } + /// + /// Returns true if file has a valid handle + /// + inline operator bool() const noexcept { return m_source; } + protected: file m_source; };