QT6函数重载 – QList重新定义QVector

huangapple go评论64阅读模式
英文:

QT6 function overloading - QList redefinition of QVector

问题

I have an compilation error "error: redefinition of 'from_json" with that code:

#include <QVector>
#include <QList>
#include <QDebug>

template<typename OwnType> void from_json(QVector<OwnType> &p)
{
    qDebug() << "QVector";
}

template<typename OwnType> void from_json(QList<OwnType> &p)
{
    qDebug() << "QList";
}

But I'm getting that compilation error only in QT6. In QT5, it compiles and works successfully. What's wrong?

C++17 MinGW

英文:

I have an compilation error "error: redefinition of 'from_json'" with that code:

#include &lt;QVector&gt;
#include &lt;QList&gt;
#include &lt;QDebug&gt;

template&lt;typename OwnType&gt; void from_json(QVector&lt;OwnType&gt; &amp;p)
{
	qDebug() &lt;&lt; &quot;QVector&quot;;
}

template&lt;typename OwnType&gt; void from_json(QList&lt;OwnType&gt; &amp;p)
{
	qDebug() &lt;&lt; &quot;QList&quot;;
}

But i getting that compilation error only in QT6. In QT5 that compilling and working successfully. Whats wrong?

c++17 MinGW

答案1

得分: 1

在Qt6中,"QVector" 只是 "QList" 的别名。

英文:

In Qt6, QVector is just an alias for QList.

huangapple
  • 本文由 发表于 2023年2月27日 17:21:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/75578636.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定