Open dangelog opened 1 year ago
Further investigation shows that template <template <typename> class X>
can match something like e.g. std::vector
only since C++17:
https://cplusplus.github.io/CWG/issues/150.html https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0522r0.html
The suggestion therefore would be to have
maybe using a macro or so.
Possible cross-test:
// C++17 only, since QVLA has a non-type template parameter
void TestAlgorithms::transformedChangeContainerAndDataType3()
{
QVector<int> vec{1, 2, 3, 4};
const auto toString = [](int i) { return QString::number(i); };
auto result = KDAlgorithms::transformed<QVarLengthArray>(vec, toString);
QVarLengthArray<QString> expected{"1", "2", "3", "4"};
QCOMPARE(result, expected);
}
A container's type may include non-type template parameters, e.g.
Accepting them with
template <typename ...> typename Container
will therefore fail:For some reason this was a deliberate choice. But why simply using
template <typename> typename Container
doesn't work here?