[libcxx-commits] [PATCH] D147850: [libc++] Implements isblank.
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Apr 8 06:00:35 PDT 2023
Mordante created this revision.
Herald added a project: All.
Mordante requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D147850
Files:
libcxx/include/__locale
libcxx/test/std/localization/locales/locale.convenience/classification/isblank.pass.cpp
Index: libcxx/test/std/localization/locales/locale.convenience/classification/isblank.pass.cpp
===================================================================
--- /dev/null
+++ 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;
+}
Index: libcxx/include/__locale
===================================================================
--- libcxx/include/__locale
+++ libcxx/include/__locale
@@ -926,6 +926,14 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147850.511883.patch
Type: text/x-patch
Size: 1764 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230408/a8824ff4/attachment.bin>
More information about the libcxx-commits
mailing list