[libcxx-commits] [PATCH] D153199: [libc++][charconv] Adds operator bool.

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 22 10:17:42 PDT 2023


ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

LGTM w/ comments and CI!



================
Comment at: libcxx/test/std/utilities/charconv/charconv.syn/from_chars_result.operator_bool.verify.cpp:19
+void test() {
+  // expected-error at +1 {{no viable conversion from 'std::from_chars_result' to 'bool'}}
+  [[maybe_unused]] bool implicit = std::from_chars_result{nullptr, std::errc{}};
----------------
I would suggest instead doing

```
static_assert(!std::is_convertible<std::from_chars_result, bool>::value);
static_assert( std::is_constructible<bool, std::from_chars_result>::value);
```

This way we are also testing that this is SFINAE-friendly, which tests `explicit` more tightly than if we check for the error. We also decouple from the error message and we're able to merge this test into the `.pass.cpp` test you added.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153199/new/

https://reviews.llvm.org/D153199



More information about the libcxx-commits mailing list