From a8fed0f50f5ef7540102b03975ac4c68bc737e66 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 19 Apr 2018 22:49:44 +1000 Subject: Templatize MakeUpperCase/MakeLowerCase so they work on char/int without casts. --- lexlib/CharacterSet.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lexlib/CharacterSet.h') diff --git a/lexlib/CharacterSet.h b/lexlib/CharacterSet.h index be906ceaa..5965f38ca 100644 --- a/lexlib/CharacterSet.h +++ b/lexlib/CharacterSet.h @@ -167,16 +167,18 @@ inline bool isoperator(int ch) { return false; } -// Simple case functions for ASCII. +// Simple case functions for ASCII supersets. -inline int MakeUpperCase(int ch) { +template +inline T MakeUpperCase(T ch) { if (ch < 'a' || ch > 'z') return ch; else - return static_cast(ch - 'a' + 'A'); + return ch - 'a' + 'A'; } -inline int MakeLowerCase(int ch) { +template +inline T MakeLowerCase(T ch) { if (ch < 'A' || ch > 'Z') return ch; else -- cgit v1.2.3