[libcxx-commits] [libcxx] [libc++][ranges] add static_assert for ranges::to (PR #135802)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Apr 15 10:03:38 PDT 2025
================
@@ -0,0 +1,17 @@
+#include <ranges>
+
+
+
+void test(){
+ struct R {
+ int* begin() const{reurn nullptr;};
+ int* end() const{return nullptr;};
+
+ operator int() const { return 0; }
+ };
+ (void)std::ranges::to<int>(R{});
+ //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
+ (void)(R{} | std::ranges::to<int>());
+ //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
+
+}
----------------
frederick-vs-ja wrote:
We conventionally add an empty line to the end of the file unless there's specific reason about lack of ending empty line.
```suggestion
}
```
https://github.com/llvm/llvm-project/pull/135802
More information about the libcxx-commits
mailing list