From 43f5db1cc123defa74c0e14a3c4b6b319d2318a8 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 24 Sep 2020 08:05:47 +1000 Subject: [PATCH] view: operator bool should be explicit Implicit bool tends to allow some unexpected behaviour when indexing with incorrect types. eg, `view a; a["foo"];` --- view.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view.hpp b/view.hpp index 1b719778..d5eab527 100644 --- a/view.hpp +++ b/view.hpp @@ -275,7 +275,7 @@ namespace cruft { ///-------------------------------------------------------------------- /// Returns true if the view is not empty; ie, there is data remaining. - constexpr operator bool () const noexcept + explicit constexpr operator bool () const noexcept { return not empty (); }