Search code examples
c++c++23stdarraystdtuple

Which feature of C++23 allows converting std::array to std::tuple?


The following code snippet implicitly converts a std::array to a std::tuple:

std::array<int,3> arr = {2,4,6};
std::tuple<int,int,int> tup;
    
tup = arr; // c++23 or later

The assignment tup = arr fails to compile with C++20, but does work with C++23. Which feature/rule of C++23 makes this possible? I do not recognize this in the list of features, e.g. as given in Wikipedia or cppreference.com.


Solution

  • This is P2165R4: Compatibility between tuple, pair and tuple-like objects.