[vlc-devel] [PATCH] vlc_shared_data_ptr: make operator bool() explicit

Romain Vimont rom1v at videolabs.io
Tue Nov 20 15:26:43 CET 2018


Like unique_ptr, make the operator bool() explicit, so that it is only
called implicitly when the value may be "contextually converted to bool"
(if, while, etc.).

Suggested-by: Filip Roséen <filip at atch.se>
---
 include/vlc_cxx_helpers.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/vlc_cxx_helpers.hpp b/include/vlc_cxx_helpers.hpp
index ed807977b1..5050d1ddb0 100644
--- a/include/vlc_cxx_helpers.hpp
+++ b/include/vlc_cxx_helpers.hpp
@@ -207,7 +207,7 @@ public:
         return !(*this == other);
     }
 
-    operator bool() const
+    explicit operator bool() const
     {
         return ptr;
     }
-- 
2.19.1



More information about the vlc-devel mailing list