[libcxx-commits] [libcxx] [libc++][optional][NFC] Use variable templates instead of class templates (PR #212443)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 28 02:30:27 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions  -- libcxx/include/optional --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/include/optional b/libcxx/include/optional
index fa7fab80c..2acd49653 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -1094,8 +1094,8 @@ public:
   template <class _Func>
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & {
     using _Up = invoke_result_t<_Func, _Tp&>;
-    static_assert(__is_std_optional_v<remove_cvref_t<_Up>>,
-                  "Result of f(value()) must be a specialization of std::optional");
+    static_assert(
+        __is_std_optional_v<remove_cvref_t<_Up>>, "Result of f(value()) must be a specialization of std::optional");
     if (*this)
       return std::invoke(std::forward<_Func>(__f), value());
     return remove_cvref_t<_Up>();
@@ -1104,8 +1104,8 @@ public:
   template <class _Func>
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const& {
     using _Up = invoke_result_t<_Func, const _Tp&>;
-    static_assert(__is_std_optional_v<remove_cvref_t<_Up>>,
-                  "Result of f(value()) must be a specialization of std::optional");
+    static_assert(
+        __is_std_optional_v<remove_cvref_t<_Up>>, "Result of f(value()) must be a specialization of std::optional");
     if (*this)
       return std::invoke(std::forward<_Func>(__f), value());
     return remove_cvref_t<_Up>();
@@ -1339,8 +1339,8 @@ public:
   template <class _Func>
   [[nodiscard]] constexpr auto and_then(_Func&& __f) const {
     using _Up = invoke_result_t<_Func, _Tp&>;
-    static_assert(__is_std_optional_v<remove_cvref_t<_Up>>,
-                  "Result of f(value()) must be a specialization of std::optional");
+    static_assert(
+        __is_std_optional_v<remove_cvref_t<_Up>>, "Result of f(value()) must be a specialization of std::optional");
     if (*this)
       return std::invoke(std::forward<_Func>(__f), value());
     return remove_cvref_t<_Up>();

``````````

</details>


https://github.com/llvm/llvm-project/pull/212443


More information about the libcxx-commits mailing list