Fixing error: 'auto' return without trailing return type; deduced return types

are a C++14 extension.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-05-28 17:25:42 +03:00
parent 7e7e9b1ee5
commit bcc2eab0fb
2 changed files with 15 additions and 6 deletions

View file

@ -356,8 +356,8 @@ enum class GSizes : unsigned char { ALL,
#endif // defined(__cplusplus) #endif // defined(__cplusplus)
#endif // QT_VERSION < QT_VERSION_CHECK(5, 8, 0) #endif // QT_VERSION < QT_VERSION_CHECK(5, 8, 0)
template <class T> template <typename T, template <typename> class Cont>
const auto & ConstFirst (const T &container) inline const T& ConstFirst (const Cont<T> &container)
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
return container.constFirst(); return container.constFirst();
@ -366,6 +366,15 @@ const auto & ConstFirst (const T &container)
#endif #endif
} }
template <typename T, typename C>
inline const T& ConstFirst (const C &container)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
return container.constFirst();
#else
return container.first(); // clazy:exclude=detaching-temporary
#endif
}
bool IsOptionSet(int argc, char *argv[], const char *option); bool IsOptionSet(int argc, char *argv[], const char *option);
void InitHighDpiScaling(int argc, char *argv[]); void InitHighDpiScaling(int argc, char *argv[]);

View file

@ -1011,10 +1011,10 @@ void VCommonSettings::SetHideLabels(bool value)
QString VCommonSettings::GetLabelDateFormat() const QString VCommonSettings::GetLabelDateFormat() const
{ {
const QString format = value(*settingLabelDateFormat, const QString format = value(*settingLabelDateFormat,
ConstFirst (VCommonSettings::PredefinedDateFormats())).toString(); ConstFirst<QString> (VCommonSettings::PredefinedDateFormats())).toString();
const QStringList allFormats = VCommonSettings::PredefinedDateFormats() + GetUserDefinedDateFormats(); const QStringList allFormats = VCommonSettings::PredefinedDateFormats() + GetUserDefinedDateFormats();
return allFormats.contains(format) ? format : ConstFirst (VCommonSettings::PredefinedDateFormats()); return allFormats.contains(format) ? format : ConstFirst<QString> (VCommonSettings::PredefinedDateFormats());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1067,10 +1067,10 @@ void VCommonSettings::SetUserDefinedDateFormats(const QStringList &formats)
QString VCommonSettings::GetLabelTimeFormat() const QString VCommonSettings::GetLabelTimeFormat() const
{ {
const QString format = value(*settingLabelTimeFormat, const QString format = value(*settingLabelTimeFormat,
ConstFirst (VCommonSettings::PredefinedTimeFormats())).toString(); ConstFirst<QString> (VCommonSettings::PredefinedTimeFormats())).toString();
const QStringList allFormats = VCommonSettings::PredefinedTimeFormats() + GetUserDefinedTimeFormats(); const QStringList allFormats = VCommonSettings::PredefinedTimeFormats() + GetUserDefinedTimeFormats();
return allFormats.contains(format) ? format : ConstFirst (VCommonSettings::PredefinedTimeFormats()); return allFormats.contains(format) ? format : ConstFirst<QString> (VCommonSettings::PredefinedTimeFormats());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------