0

I have been using this function for quite some time in Qt5:

static QString demangle( const QString &name )
{
    int status;
    std::unique_ptr< char, void(*)( void* ) > res (
        abi::__cxa_demangle( name.toLatin1(), nullptr, nullptr, &status ), std::free );
    return { ( status == 0 ) ? QLatin1String( res.get() ) : name };
}

Since starting to use Qt6,

ct_Halt( demangle(typeid (QStringList).name() ), demangle(typeid (QList<QString>).name() ) );

now produces

QString demangle(typeid (QStringList).name() )
"QList<QString>" // This used to produce QStringList in Qt5

QString demangle(typeid (QList<QString>).name() )
"QList<QString>"

This little annoyance has broken a library that I created. Its not a big deal but I'd like to know if the demangle function can be "fixed" to accurately reflect the typename.

Anon
  • 2,267
  • 3
  • 34
  • 51
  • 2
    In Qt6, [`QStringList` is an alias of `QList`](https://github.com/qt/qtbase/blob/6.0/src/corelib/tools/qcontainerfwd.h#L65), so they are exactly the same type. There is no way to distinguish between them. – kakkoko Nov 25 '21 at 02:09
  • I suspected that was the case. I am kind of surprised though and am curious how they did that, considering there are some QStringList specific functions, like "replaceInStrings" – Anon Nov 25 '21 at 02:12
  • @Anon why is that surprising? `QStringList` is still a type. Just because it now aliases another type doesn't mean it can't still be used as itself. The only real issue would be if there were a function with a `QList` argument, and an *overloaded* function using the same arguments except for `QStringList` instead. That would be ambiguous. Otherwise, you shouldn't need to concern yourself with how `QStringList` is *implemented*, as long as its interface is consistent with what you are expecting. – Remy Lebeau Nov 25 '21 at 03:31

0 Answers0