Skip to content

Strange formatting of a requires containing an array #53864

Closed
@mordante

Description

I tested with clang-format after https://reviews.llvm.org/D113319 landed and found some issues in new code. This looks similar to #53820, but I'm not sure whether it's the same issue.
I used this config

BasedOnStyle: LLVM
  
---
Language: Cpp
Standard: c++20

Code (for libc++ so uses __ugly_names)

template <class _Context, class _Tp>
  requires is_array_v<_Tp> &&
           same_as<_Tp, typename _Context::char_type[extent_v<_Tp>
]> consteval auto
  __make_storage_type() {
  return __storage_type<basic_string_view<typename _Context::char_type>>{};
}

I would expect this part to be on one line same_as<_Tp, typename _Context::char_type[extent_v<_Tp>]>
Using parens solves the issue

template <class _Context, class _Tp>
  requires(is_array_v<_Tp> &&
           same_as<_Tp, typename _Context::char_type[extent_v<_Tp>]>)
consteval auto __make_storage_type() {
  return __storage_type<basic_string_view<typename _Context::char_type>>{};
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

bugIndicates an unexpected problem or unintended behaviorclang-formatconfirmedVerified by a second party

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions