Skip to content

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Jan 23, 2024

Previously, there was a ternary conditional with a less-than comparison appearing inside a template argument, which was really confusing because of the <...> of the function template. This patch rewrites the same statement on two lines for clarity.

Previously, there was a ternary conditional with a less-than comparison
appearing inside a template argument, which was really confusing because
of the <...> of the function template. This patch rewrites the same
statement on two lines for clarity.
@ldionne ldionne requested a review from a team as a code owner January 23, 2024 14:22
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jan 23, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 23, 2024

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

Previously, there was a ternary conditional with a less-than comparison appearing inside a template argument, which was really confusing because of the <...> of the function template. This patch rewrites the same statement on two lines for clarity.


Full diff: https://github.com/llvm/llvm-project/pull/79141.diff

1 Files Affected:

  • (modified) libcxx/include/string (+2-2)
diff --git a/libcxx/include/string b/libcxx/include/string
index e97139206d4fa7c..085178fe1a9ed01 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -1948,8 +1948,8 @@ private:
     if (__s < __min_cap) {
       return static_cast<size_type>(__min_cap) - 1;
     }
-    size_type __guess =
-        __align_it < sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : 1 > (__s + 1) - 1;
+    const size_type __boundary = sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : 1;
+    size_type __guess          = __align_it<__boundary>(__s + 1) - 1;
     if (__guess == __min_cap)
       ++__guess;
     return __guess;

@ldionne ldionne merged commit 382f70a into llvm:main Jan 24, 2024
@ldionne ldionne deleted the review/nfc-string-alignment branch January 24, 2024 14:29
llvmbot pushed a commit to llvmbot/llvm-project that referenced this pull request Jun 12, 2024
)

Previously, there was a ternary conditional with a less-than comparison
appearing inside a template argument, which was really confusing because
of the <...> of the function template. This patch rewrites the same
statement on two lines for clarity.

(cherry picked from commit 382f70a)
vitalybuka pushed a commit that referenced this pull request Jun 12, 2024
Previously, there was a ternary conditional with a less-than comparison
appearing inside a template argument, which was really confusing because
of the <...> of the function template. This patch rewrites the same
statement on two lines for clarity.

(cherry picked from commit 382f70a)
llvmbot pushed a commit to llvmbot/llvm-project that referenced this pull request Jun 15, 2024
)

Previously, there was a ternary conditional with a less-than comparison
appearing inside a template argument, which was really confusing because
of the <...> of the function template. This patch rewrites the same
statement on two lines for clarity.

(cherry picked from commit 382f70a)
owenca pushed a commit to owenca/llvm-project that referenced this pull request Jun 22, 2024
)

Previously, there was a ternary conditional with a less-than comparison
appearing inside a template argument, which was really confusing because
of the <...> of the function template. This patch rewrites the same
statement on two lines for clarity.

(cherry picked from commit 382f70a)
Tedlion pushed a commit to Tedlion/llvm-project that referenced this pull request Jun 15, 2025
)

Previously, there was a ternary conditional with a less-than comparison
appearing inside a template argument, which was really confusing because
of the <...> of the function template. This patch rewrites the same
statement on two lines for clarity.

(cherry picked from commit 382f70a)
Tedlion pushed a commit to Tedlion/llvm-project that referenced this pull request Jun 15, 2025
)

Previously, there was a ternary conditional with a less-than comparison
appearing inside a template argument, which was really confusing because
of the <...> of the function template. This patch rewrites the same
statement on two lines for clarity.

(cherry picked from commit 382f70a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants