Open mhoemmen opened 2 years ago
Also, span
lets you assign static to dynamic.
https://eel.is/c++draft/span.cons lets you assign both directions (static to dynamic, or dynamic to static)
Tomasz Kamiński pointed out this issue
span permits construction from dynamic to static, but not assignment: https://godbolt.org/z/4eEMWzYzW
which is silly, because you can always construct an intermediate span, then assign
Both of these cases are important. Static-to-dynamic conversion is "type erasure," for when an implementation doesn't want to specialize for compile-time extents. Dynamic-to-static conversion is "specialization" (the opposite of type erasure), for when an implementation is willing to pay the compile-time cost of specializing. A common use case for the latter is in applications that solve partial differential equations through a variety of different discretization methods. Many methods result in arrays with known fixed extents, but making all of them compile-time constants might cost too much compilation time, rather than just optimizing the most common methods.