[libcxx-commits] [libcxx] [libc++] Add __simple_tuple and replace a bunch of uses of tuple with it (PR #214566)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Aug 19 12:01:34 PDT 2026


================
@@ -484,20 +482,14 @@ public:
       : __t_(__margs...) {}
 
   _LIBCPP_RELEASE_CAPABILITY() _LIBCPP_HIDE_FROM_ABI ~scoped_lock() {
-    __unlock_unpack(make_index_sequence<sizeof...(_MArgs)>(), __t_);
+    _TupleT::__apply(__t_, [] _LIBCPP_NO_THREAD_SAFETY_ANALYSIS(auto&... __args) { (__args.unlock(), ...); });
----------------
higher-performance wrote:

I'm thinking of this, which reduces the number of class types instantiated:
```
#include <type_traits>

auto make_foo() { return [](auto&...) {}; }

template<class... T>
struct scoped_lock {
    auto foo() { return [](T&...) {}; }
    auto bar() { return make_foo(); }
};

int main() {
    static_assert(!std::is_same<decltype(scoped_lock<int>().foo()), decltype(scoped_lock<char>().foo())>::value);
    static_assert(std::is_same<decltype(scoped_lock<int>().bar()), decltype(scoped_lock<char>().bar())>::value);
}
```

https://github.com/llvm/llvm-project/pull/214566


More information about the libcxx-commits mailing list