[libcxx-commits] [PATCH] D96477: [libcxx] adds remaining callable concepts

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Mar 21 15:29:50 PDT 2021


zoecarver added inline comments.


================
Comment at: libcxx/test/std/concepts/callable/functions.h:27-28
+struct Bool {
+  int Value = false;
+  constexpr operator bool() const noexcept { return Value; }
+};
----------------
Quuxplusone wrote:
> zoecarver wrote:
> > Quuxplusone wrote:
> > > cjdb wrote:
> > > > Quuxplusone wrote:
> > > > > 
> > > > No, this is definitely correct as-is.
> > > There is no //conceivable// library bug that could cause us to treat `int Value = false;` and `int Value = 0;` any differently.
> > > Also, you don't want to return `int Value` from `operator bool`; you want to return a `bool`.
> > > 
> > > Maybe you meant to write `bool Value = false;` instead of `int Value = false;`, is that the issue?
> > @Quuxplusone why do you want to remove noexcept? 
> Well, I'm always on the side of "keep it simple/short." Nothing in C++ cares about whether your conversion-to-`bool` operator is noexcept, so there's no reason to make it noexcept. (Also, it'll rarely if ever be noexcept in real-world code, so one could argue that testing shorter code is also testing //more realistic// code.)
Fair enough. FWIW I don't feel strongly one way or another about the noexcept. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96477



More information about the libcxx-commits mailing list