lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 40bee87 7/7: Work around a [bitmask.types] is


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 40bee87 7/7: Work around a [bitmask.types] issue
Date: Tue, 13 Nov 2018 12:21:37 -0500 (EST)

branch: master
commit 40bee8774d9a169e5025ea622e874ec775e001d8
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Work around a [bitmask.types] issue
    
    See:
      https://lists.nongnu.org/archive/html/lmi/2018-11/msg00021.html
    et seqq.
---
 facets.cpp | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/facets.cpp b/facets.cpp
index 2aeb705..677629c 100644
--- a/facets.cpp
+++ b/facets.cpp
@@ -87,17 +87,9 @@
 // The underlying problem is that 'short unsigned int' does not fulfill the
 // bitmask requirements, as unary operator ~ performs integral promotions.
 //
-// This would avoid the warning:
+// This:
 //   rc[C] &= static_cast<std::ctype_base::mask>(~std::ctype_base::space);
-// but seems too violent. This does not avoid the warning:
-//   constexpr auto z = ~std::ctype_base::space;
-//   rc[C] &= z;
-// due to integral promotion. And braces are not allowed here:
-//   rc[C] &= {~std::ctype_base::space};
-// so this code (used in the implementation below):
-//   constexpr std::ctype_base::mask z = {~std::ctype_base::space};
-//   rc[C] &= z;
-// is the least awful thing that works.
+// is the least awful workaround that avoids the warning.
 
 namespace
 {
@@ -115,8 +107,7 @@ namespace
             static std::ctype_base::mask rc[table_size];
             std::copy(classic_table(), classic_table() + table_size, rc);
             // See "Implementation note" above.
-            constexpr std::ctype_base::mask z = {~std::ctype_base::space};
-            rc[C] &= z;
+            rc[C] &= 
static_cast<std::ctype_base::mask>(~std::ctype_base::space);
             return rc;
             }
     };



reply via email to

[Prev in Thread] Current Thread [Next in Thread]