Thread View: pl.comp.lang.c
2 messages
2 total messages
Started by Maciek
Tue, 02 Apr 2019 09:26
Ostrzeżenie z bibliteki QT 5.12.0 - Visual c++ 2019
Author: Maciek
Date: Tue, 02 Apr 2019 09:26
Date: Tue, 02 Apr 2019 09:26
43 lines
2919 bytes
2919 bytes
Dzień Dobry. Kompilator C++ w Visual Studio 2019 jako ostrzeżenie daje mi w poniższej sytuacji:
1>E:\QT\5.12.0\msvc2017\include\QtTest\qtestcase.h(418): warning C4805: '==': unsafe mix of type 'const T1' and type 'const T2' in operation
1> with
1> [
1> T1=bool
1> ]
1> and
1> [
1> T2=int
1> ] (compiling source file Tests.cpp)
1>C:\Users\M91P\source\repos\Newmen_Style\newmen_prices_calc\newmen_prices_calc\Tests.cpp(32): note: see reference to function template instantiation 'bool QTest::qCompare<bool,int>(const T1 &,const T2 &,const char *,const char *,const char *,int)' being compiled
1> with
1> [
1> T1=bool,
1> T2=int
1> ]
fragment o który chodzi:
template <typename T1, typename T2>
inline bool qCompare(const T1 &t1, const T2 &t2, const char *actual, const char *expected,
const char *file, int line)
{
return compare_helper(t1 == t2, "Compared values are not the same",
toString(t1), toString(t2), actual, expected, file, line);
}
Czy można to naprawić dając statyczne rzutowanie:
template <typename T1, typename T2>
inline bool qCompare(const T1 &t1, const T2 &t2, const char *actual, const char *expected,
const char *file, int line)
{
return compare_helper(t1 == static_cast<T1>(t2), "Compared values are not the same",
toString(t1), toString(t2), actual, expected, file, line);
}
???
Z góry dziękuję za odpowiedź.
Re: Ostrzeżenie z bibliteki QT 5.12.0 - Visual c++ 2019
Author: Szyk Cech
Date: Sun, 14 Apr 2019 14:22
Date: Sun, 14 Apr 2019 14:22
3 lines
1316 bytes
1316 bytes
Jaki jest sens porównywania dwóch odrębnych typów? Jest to nie dopuszczane również w sytuacji gdy jeden jest potomkiem drugiego. Gdyż operatorów się nie dziedziczy.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads