[libcxx-commits] [libcxx] 0bc0edb - [libc++] Implements isblank.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sun Apr 9 04:13:06 PDT 2023


Author: Mark de Wever
Date: 2023-04-09T13:11:59+02:00
New Revision: 0bc0edb847a0cc473a8b005c4725948de3306a20

URL: https://github.com/llvm/llvm-project/commit/0bc0edb847a0cc473a8b005c4725948de3306a20
DIFF: https://github.com/llvm/llvm-project/commit/0bc0edb847a0cc473a8b005c4725948de3306a20.diff

LOG: [libc++] Implements isblank.

This omission seems to be there for a long time, it's in the initial
libc++ import. This was discovered while working on the std modules.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D147850

Added: 
    libcxx/test/std/localization/locales/locale.convenience/classification/isblank.pass.cpp

Modified: 
    libcxx/include/__locale

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__locale b/libcxx/include/__locale
index 9b548d738d181..b461831a9979e 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -927,6 +927,11 @@ isgraph(_CharT __c, const locale& __loc)
     return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c);
 }
 
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI bool isblank(_CharT __c, const locale& __loc) {
+    return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::blank, __c);
+}
+
 template <class _CharT>
 inline _LIBCPP_INLINE_VISIBILITY
 _CharT

diff  --git a/libcxx/test/std/localization/locales/locale.convenience/classification/isblank.pass.cpp b/libcxx/test/std/localization/locales/locale.convenience/classification/isblank.pass.cpp
new file mode 100644
index 0000000000000..2a5cc19b3c5ed
--- /dev/null
+++ b/libcxx/test/std/localization/locales/locale.convenience/classification/isblank.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isblank (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main(int, char**) {
+  std::locale l;
+  assert(std::isblank(' ', l));
+  assert(!std::isblank('<', l));
+  assert(!std::isblank('\x8', l));
+  assert(!std::isblank('A', l));
+  assert(!std::isblank('a', l));
+  assert(!std::isblank('z', l));
+  assert(!std::isblank('3', l));
+  assert(!std::isblank('.', l));
+  assert(!std::isblank('f', l));
+  assert(!std::isblank('9', l));
+  assert(!std::isblank('+', l));
+
+  return 0;
+}


        


More information about the libcxx-commits mailing list