I love Nico's pragmatic approach to C++. Always great to hear from him.
@MindGameArcade2 жыл бұрын
Fantastic talk
@alltheway992 жыл бұрын
Excellent presentation
@AM-qx3bq2 жыл бұрын
I enjoyed the talk. I fail to see why that intermediate vector was necessary in the merge function...just use the array in the first place? Also, returning the size of the array as a pair element, it's an array so the size is encoded within its type if the user wants it...no?
@Qazqi2 жыл бұрын
Any way you compute the final size, it's not going to be a constant expression because the information of how many elements to leave out (the intersection) is not present in the template parameters in any form. As the slides show, the best you can do is a maximum size, and that's only because the input array's size is present within its template parameter, making the `size()` call on it a constant expression. Even though the data is known at compile-time, you cannot instantiate a template (`std::array`) during constant evaluation, so anything that requires waiting until you're evaluating the function call to determine the size is too late. Given that, the other part of your comment can be answered by saying that it's not returning the actual array, it's returning a max-size array and then an accompanying size to indicate how much of that array is used.