← Back to team overview

kicad-developers team mailing list archive

[PATCH] Avoid initialization from non-constexpr

 

In-class initializers for "static const" class members must be constexpr,
however std::string is only "static const" itself and cannot be used
without compiler extensions.
---
 include/utf8.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/utf8.h b/include/utf8.h
index 26c467f0d..e78e8fd09 100644
--- a/include/utf8.h
+++ b/include/utf8.h
@@ -145,7 +145,9 @@ public:
         return (UTF8&) *this;
     }
 
-    static const std::string::size_type npos = std::string::npos;
+    // std::string::npos is not constexpr, so we can't use it in an
+    // initializer.
+    static constexpr std::string::size_type npos = -1;
 
     UTF8& operator=( const wxString& o );