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

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Mar 21 15:22:19 PDT 2021


Quuxplusone 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; }
+};
----------------
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.)


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