https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89417

--- Comment #6 from Federico Kircheis <federico.kircheis at gmail dot com> ---
For what is worth, I imagined the implementation for parameters of different
type and more or less than two to be similar to

----
template <class...Args>
auto sorted_indexes(Args&... args) {
    const void* addresses[] = {&args...};
    std::array<int,std::size(addresses)> indexes{};
    std::iota(std::begin(indexes), std::end(indexes), 0);
    std::sort(std::begin(indexes), std::end(indexes), [&](int i1, int i2){
        return std::less<void>()(addresses[i1], addresses[i2]);
    });
    return indexes;
}


template <class...Args>
auto create_lock(Args&... args){
    auto indexes = sorted_indexes(args...);
    return std::scoped_lock(args[indexes]...); // ???
}
----

But it's probably a dead end, as args is not an array and I see no way to use
the computed index.

Reply via email to