wip:msvc phrase cast fix

This commit is contained in:
Hamed Masafi 2019-02-26 18:23:57 +03:30
parent 0857a7b165
commit 2a60f0c00e
5 changed files with 29 additions and 21 deletions

2
3rdparty/serializer vendored

@ -1 +1 @@
Subproject commit 1d3495bed909392cdf128e8ef6f8b3986b2c09b5
Subproject commit b3c550c5bb7c570b1b10492fcedf287c1915af39

View File

@ -15,11 +15,11 @@ public:
AbstractFieldPhrase(className, s)
{}
AssignmentPhrase operator =(const T &other) {
AssignmentPhrase operator =(const QVariant &other) {
return AssignmentPhrase(this, other);
}
ConditionalPhrase operator ==(const T &other) {
ConditionalPhrase operator ==(const QVariant &other) {
return ConditionalPhrase(this, PhraseData::Equal, other);
}

View File

@ -6,14 +6,16 @@
NUT_BEGIN_NAMESPACE
#define SPECIALIZATION_NUMERIC_MEMBER(type, op, cond) \
ConditionalPhrase operator op(const QVariant &other) \
{ \
return ConditionalPhrase(this, cond, other); \
}
#define SPECIALIZATION_NUMERIC_MEMBER(type, op, cond) \
ConditionalPhrase operator op(const QVariant &other) \
{ \
return ConditionalPhrase(this, cond, other); \
}
template <typename T>
class FieldPhrase<T, typename std::enable_if<std::is_integral<T>::value>::type>
class FieldPhrase<T, typename std::enable_if<
std::is_floating_point<T>::value || std::is_integral<T>::value
>::type>
: public AbstractFieldPhrase
{
public:
@ -21,17 +23,6 @@ public:
AbstractFieldPhrase(className, s)
{}
SPECIALIZATION_NUMERIC_MEMBER(type, <, PhraseData::Less)
SPECIALIZATION_NUMERIC_MEMBER(type, <=, PhraseData::LessEqual)
SPECIALIZATION_NUMERIC_MEMBER(type, >, PhraseData::Greater)
SPECIALIZATION_NUMERIC_MEMBER(type, >=, PhraseData::GreaterEqual)
SPECIALIZATION_NUMERIC_MEMBER(type, %, PhraseData::Mod)
SPECIALIZATION_NUMERIC_MEMBER(type, +, PhraseData::Add)
SPECIALIZATION_NUMERIC_MEMBER(type, -, PhraseData::Minus)
SPECIALIZATION_NUMERIC_MEMBER(type, *, PhraseData::Multiple)
SPECIALIZATION_NUMERIC_MEMBER(type, /, PhraseData::Divide)
AssignmentPhrase operator =(const QVariant &other) {
return AssignmentPhrase(this, other);
}
@ -59,6 +50,17 @@ public:
{
return ConditionalPhrase(this, PhraseData::Minus, 1);
}
SPECIALIZATION_NUMERIC_MEMBER(type, <, PhraseData::Less)
SPECIALIZATION_NUMERIC_MEMBER(type, <=, PhraseData::LessEqual)
SPECIALIZATION_NUMERIC_MEMBER(type, >, PhraseData::Greater)
SPECIALIZATION_NUMERIC_MEMBER(type, >=, PhraseData::GreaterEqual)
SPECIALIZATION_NUMERIC_MEMBER(type, %, PhraseData::Mod)
SPECIALIZATION_NUMERIC_MEMBER(type, +, PhraseData::Add)
SPECIALIZATION_NUMERIC_MEMBER(type, -, PhraseData::Minus)
SPECIALIZATION_NUMERIC_MEMBER(type, *, PhraseData::Multiple)
SPECIALIZATION_NUMERIC_MEMBER(type, /, PhraseData::Divide)
};
#define SPECIALIZATION_NUMERIC_TYPE(type) \

View File

@ -1,5 +1,4 @@
QT += testlib sql
QT -= gui
TARGET = tst_datatypes
TEMPLATE = app

View File

@ -27,6 +27,7 @@ void MainTest::no1()
void MainTest::numeric()
{
FieldPhrase<int> n("main", "int");
FieldPhrase<float> f("main", "float");
auto p1 = n == 1;
auto p2 = n <= 1;
@ -43,6 +44,12 @@ void MainTest::numeric()
auto p13 = ++n;
auto p14 = n++;
auto p15 = n.between(1, 2);
auto p16 = n + 1 < n + 2;
auto p21 = p1 && p2;
auto p22 = p3 == p4;
auto p23 = f == n + 1;
}
void MainTest::string()