[libcxx-commits] [libcxx] [libc++][NFC] Update <any> to a more modern code style (PR #174619)
Alexander Kornienko via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jan 15 09:30:34 PST 2026
alexfh wrote:
> #include <any>
> #include <utility>
> #include "absl/status/statusor.h"
>
> class Foo {
> public:
> Foo() = default;
>
> static Foo Repack(absl::StatusOr<Foo> v) {
> return std::move(v).value();
> }
>
> private:
> explicit Foo(std::any value) : value_(std::move(value)) {};
>
> std::any value_;
> };
This boils down to the following (https://gcc.godbolt.org/z/oTfWdGvnd):
```
#include <any>
struct Foo {
Foo(std::any v);
};
template <typename T, bool = std::is_copy_constructible<T>::value>
void f(T) {}
void q(Foo x) { f(x); }
```
https://github.com/llvm/llvm-project/pull/174619
More information about the libcxx-commits
mailing list