EricWF wrote:

Oh, I just noticed there are no tests for exception safety. Could you please 
add some throwing types? (Or perhaps I just missed those tests?).

Currently this code terminates:
```
#include <functional>
#include <cassert>

struct ThrowsOnConstruct {
  explicit ThrowsOnConstruct(int x) : value(x) { if (x == 42) throw 42; }
  ThrowsOnConstruct(ThrowsOnConstruct const&) = delete;
  ThrowsOnConstruct(ThrowsOnConstruct && other) : value(other.value) { if 
(other.value == 101) throw 101; other.value = -1; }

  ~ThrowsOnConstruct() {
    assert(value != -1);
    value = -1;
  }

  int operator()() const noexcept { return value; }

  int value;
};

int main() {
  using MV = std::move_only_function<int() const>;
  try {
    MV f(ThrowsOnConstruct(101));
  } catch (...) {
  }
}
```

In particular, I don't think this constructor can be `noexcept`. 

I also think there are some missing tests for reference_wrapper. 

https://github.com/llvm/llvm-project/pull/94670
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to