Skip to content

Commit d51e3cf

Browse files
authored
Merge pull request #1159 from FireDaemon/issues/#1047
Operators should be in internal namespace
2 parents e364960 + 46fa6c9 commit d51e3cf

File tree

4 files changed

+334
-261
lines changed

4 files changed

+334
-261
lines changed

dev/conditions.h

Lines changed: 134 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -843,167 +843,171 @@ namespace sqlite_orm {
843843
return {std::move(arg)};
844844
}
845845

846-
/**
847-
* Cute operators for columns
848-
*/
849-
template<class T, class R>
850-
internal::lesser_than_t<T, R> operator<(internal::expression_t<T> expr, R r) {
851-
return {std::move(expr.value), std::move(r)};
852-
}
846+
// Deliberately put operators for `expression_t` into the internal namespace
847+
// to facilitate ADL (Argument Dependent Lookup)
848+
namespace internal {
849+
/**
850+
* Cute operators for columns
851+
*/
852+
template<class T, class R>
853+
lesser_than_t<T, R> operator<(expression_t<T> expr, R r) {
854+
return {std::move(expr.value), std::move(r)};
855+
}
853856

854-
template<class L, class T>
855-
internal::lesser_than_t<L, T> operator<(L l, internal::expression_t<T> expr) {
856-
return {std::move(l), std::move(expr.value)};
857-
}
857+
template<class L, class T>
858+
lesser_than_t<L, T> operator<(L l, expression_t<T> expr) {
859+
return {std::move(l), std::move(expr.value)};
860+
}
858861

859-
template<class T, class R>
860-
internal::lesser_or_equal_t<T, R> operator<=(internal::expression_t<T> expr, R r) {
861-
return {std::move(expr.value), std::move(r)};
862-
}
862+
template<class T, class R>
863+
lesser_or_equal_t<T, R> operator<=(expression_t<T> expr, R r) {
864+
return {std::move(expr.value), std::move(r)};
865+
}
863866

864-
template<class L, class T>
865-
internal::lesser_or_equal_t<L, T> operator<=(L l, internal::expression_t<T> expr) {
866-
return {std::move(l), std::move(expr.value)};
867-
}
867+
template<class L, class T>
868+
lesser_or_equal_t<L, T> operator<=(L l, expression_t<T> expr) {
869+
return {std::move(l), std::move(expr.value)};
870+
}
868871

869-
template<class T, class R>
870-
internal::greater_than_t<T, R> operator>(internal::expression_t<T> expr, R r) {
871-
return {std::move(expr.value), std::move(r)};
872-
}
872+
template<class T, class R>
873+
greater_than_t<T, R> operator>(expression_t<T> expr, R r) {
874+
return {std::move(expr.value), std::move(r)};
875+
}
873876

874-
template<class L, class T>
875-
internal::greater_than_t<L, T> operator>(L l, internal::expression_t<T> expr) {
876-
return {std::move(l), std::move(expr.value)};
877-
}
877+
template<class L, class T>
878+
greater_than_t<L, T> operator>(L l, expression_t<T> expr) {
879+
return {std::move(l), std::move(expr.value)};
880+
}
878881

879-
template<class T, class R>
880-
internal::greater_or_equal_t<T, R> operator>=(internal::expression_t<T> expr, R r) {
881-
return {std::move(expr.value), std::move(r)};
882-
}
882+
template<class T, class R>
883+
greater_or_equal_t<T, R> operator>=(expression_t<T> expr, R r) {
884+
return {std::move(expr.value), std::move(r)};
885+
}
883886

884-
template<class L, class T>
885-
internal::greater_or_equal_t<L, T> operator>=(L l, internal::expression_t<T> expr) {
886-
return {std::move(l), std::move(expr.value)};
887-
}
887+
template<class L, class T>
888+
greater_or_equal_t<L, T> operator>=(L l, expression_t<T> expr) {
889+
return {std::move(l), std::move(expr.value)};
890+
}
888891

889-
template<class T, class R>
890-
internal::is_equal_t<T, R> operator==(internal::expression_t<T> expr, R r) {
891-
return {std::move(expr.value), std::move(r)};
892-
}
892+
template<class T, class R>
893+
is_equal_t<T, R> operator==(expression_t<T> expr, R r) {
894+
return {std::move(expr.value), std::move(r)};
895+
}
893896

894-
template<class L, class T>
895-
internal::is_equal_t<L, T> operator==(L l, internal::expression_t<T> expr) {
896-
return {std::move(l), std::move(expr.value)};
897-
}
897+
template<class L, class T>
898+
is_equal_t<L, T> operator==(L l, expression_t<T> expr) {
899+
return {std::move(l), std::move(expr.value)};
900+
}
898901

899-
template<class T, class R>
900-
internal::is_not_equal_t<T, R> operator!=(internal::expression_t<T> expr, R r) {
901-
return {std::move(expr.value), std::move(r)};
902-
}
902+
template<class T, class R>
903+
is_not_equal_t<T, R> operator!=(expression_t<T> expr, R r) {
904+
return {std::move(expr.value), std::move(r)};
905+
}
903906

904-
template<class L, class T>
905-
internal::is_not_equal_t<L, T> operator!=(L l, internal::expression_t<T> expr) {
906-
return {std::move(l), std::move(expr.value)};
907-
}
907+
template<class L, class T>
908+
is_not_equal_t<L, T> operator!=(L l, expression_t<T> expr) {
909+
return {std::move(l), std::move(expr.value)};
910+
}
908911

909-
template<class T, class R>
910-
internal::conc_t<T, R> operator||(internal::expression_t<T> expr, R r) {
911-
return {std::move(expr.value), std::move(r)};
912-
}
912+
template<class T, class R>
913+
conc_t<T, R> operator||(expression_t<T> expr, R r) {
914+
return {std::move(expr.value), std::move(r)};
915+
}
913916

914-
template<class L, class T>
915-
internal::conc_t<L, T> operator||(L l, internal::expression_t<T> expr) {
916-
return {std::move(l), std::move(expr.value)};
917-
}
917+
template<class L, class T>
918+
conc_t<L, T> operator||(L l, expression_t<T> expr) {
919+
return {std::move(l), std::move(expr.value)};
920+
}
918921

919-
template<class L, class R>
920-
internal::conc_t<L, R> operator||(internal::expression_t<L> l, internal::expression_t<R> r) {
921-
return {std::move(l.value), std::move(r.value)};
922-
}
922+
template<class L, class R>
923+
conc_t<L, R> operator||(expression_t<L> l, expression_t<R> r) {
924+
return {std::move(l.value), std::move(r.value)};
925+
}
923926

924-
template<class R, class E, internal::satisfies<std::is_base_of, internal::conc_string, E> = true>
925-
internal::conc_t<E, R> operator||(E expr, R r) {
926-
return {std::move(expr), std::move(r)};
927-
}
927+
template<class R, class E, satisfies<std::is_base_of, conc_string, E> = true>
928+
conc_t<E, R> operator||(E expr, R r) {
929+
return {std::move(expr), std::move(r)};
930+
}
928931

929-
template<class L, class E, internal::satisfies<std::is_base_of, internal::conc_string, E> = true>
930-
internal::conc_t<L, E> operator||(L l, E expr) {
931-
return {std::move(l), std::move(expr)};
932-
}
932+
template<class L, class E, satisfies<std::is_base_of, conc_string, E> = true>
933+
conc_t<L, E> operator||(L l, E expr) {
934+
return {std::move(l), std::move(expr)};
935+
}
933936

934-
template<class T, class R>
935-
internal::add_t<T, R> operator+(internal::expression_t<T> expr, R r) {
936-
return {std::move(expr.value), std::move(r)};
937-
}
937+
template<class T, class R>
938+
add_t<T, R> operator+(expression_t<T> expr, R r) {
939+
return {std::move(expr.value), std::move(r)};
940+
}
938941

939-
template<class L, class T>
940-
internal::add_t<L, T> operator+(L l, internal::expression_t<T> expr) {
941-
return {std::move(l), std::move(expr.value)};
942-
}
942+
template<class L, class T>
943+
add_t<L, T> operator+(L l, expression_t<T> expr) {
944+
return {std::move(l), std::move(expr.value)};
945+
}
943946

944-
template<class L, class R>
945-
internal::add_t<L, R> operator+(internal::expression_t<L> l, internal::expression_t<R> r) {
946-
return {std::move(l.value), std::move(r.value)};
947-
}
947+
template<class L, class R>
948+
add_t<L, R> operator+(expression_t<L> l, expression_t<R> r) {
949+
return {std::move(l.value), std::move(r.value)};
950+
}
948951

949-
template<class T, class R>
950-
internal::sub_t<T, R> operator-(internal::expression_t<T> expr, R r) {
951-
return {std::move(expr.value), std::move(r)};
952-
}
952+
template<class T, class R>
953+
sub_t<T, R> operator-(expression_t<T> expr, R r) {
954+
return {std::move(expr.value), std::move(r)};
955+
}
953956

954-
template<class L, class T>
955-
internal::sub_t<L, T> operator-(L l, internal::expression_t<T> expr) {
956-
return {std::move(l), std::move(expr.value)};
957-
}
957+
template<class L, class T>
958+
sub_t<L, T> operator-(L l, expression_t<T> expr) {
959+
return {std::move(l), std::move(expr.value)};
960+
}
958961

959-
template<class L, class R>
960-
internal::sub_t<L, R> operator-(internal::expression_t<L> l, internal::expression_t<R> r) {
961-
return {std::move(l.value), std::move(r.value)};
962-
}
962+
template<class L, class R>
963+
sub_t<L, R> operator-(expression_t<L> l, expression_t<R> r) {
964+
return {std::move(l.value), std::move(r.value)};
965+
}
963966

964-
template<class T, class R>
965-
internal::mul_t<T, R> operator*(internal::expression_t<T> expr, R r) {
966-
return {std::move(expr.value), std::move(r)};
967-
}
967+
template<class T, class R>
968+
mul_t<T, R> operator*(expression_t<T> expr, R r) {
969+
return {std::move(expr.value), std::move(r)};
970+
}
968971

969-
template<class L, class T>
970-
internal::mul_t<L, T> operator*(L l, internal::expression_t<T> expr) {
971-
return {std::move(l), std::move(expr.value)};
972-
}
972+
template<class L, class T>
973+
mul_t<L, T> operator*(L l, expression_t<T> expr) {
974+
return {std::move(l), std::move(expr.value)};
975+
}
973976

974-
template<class L, class R>
975-
internal::mul_t<L, R> operator*(internal::expression_t<L> l, internal::expression_t<R> r) {
976-
return {std::move(l.value), std::move(r.value)};
977-
}
977+
template<class L, class R>
978+
mul_t<L, R> operator*(expression_t<L> l, expression_t<R> r) {
979+
return {std::move(l.value), std::move(r.value)};
980+
}
978981

979-
template<class T, class R>
980-
internal::div_t<T, R> operator/(internal::expression_t<T> expr, R r) {
981-
return {std::move(expr.value), std::move(r)};
982-
}
982+
template<class T, class R>
983+
div_t<T, R> operator/(expression_t<T> expr, R r) {
984+
return {std::move(expr.value), std::move(r)};
985+
}
983986

984-
template<class L, class T>
985-
internal::div_t<L, T> operator/(L l, internal::expression_t<T> expr) {
986-
return {std::move(l), std::move(expr.value)};
987-
}
987+
template<class L, class T>
988+
div_t<L, T> operator/(L l, expression_t<T> expr) {
989+
return {std::move(l), std::move(expr.value)};
990+
}
988991

989-
template<class L, class R>
990-
internal::div_t<L, R> operator/(internal::expression_t<L> l, internal::expression_t<R> r) {
991-
return {std::move(l.value), std::move(r.value)};
992-
}
992+
template<class L, class R>
993+
div_t<L, R> operator/(expression_t<L> l, expression_t<R> r) {
994+
return {std::move(l.value), std::move(r.value)};
995+
}
993996

994-
template<class T, class R>
995-
internal::mod_t<T, R> operator%(internal::expression_t<T> expr, R r) {
996-
return {std::move(expr.value), std::move(r)};
997-
}
997+
template<class T, class R>
998+
mod_t<T, R> operator%(expression_t<T> expr, R r) {
999+
return {std::move(expr.value), std::move(r)};
1000+
}
9981001

999-
template<class L, class T>
1000-
internal::mod_t<L, T> operator%(L l, internal::expression_t<T> expr) {
1001-
return {std::move(l), std::move(expr.value)};
1002-
}
1002+
template<class L, class T>
1003+
mod_t<L, T> operator%(L l, expression_t<T> expr) {
1004+
return {std::move(l), std::move(expr.value)};
1005+
}
10031006

1004-
template<class L, class R>
1005-
internal::mod_t<L, R> operator%(internal::expression_t<L> l, internal::expression_t<R> r) {
1006-
return {std::move(l.value), std::move(r.value)};
1007+
template<class L, class R>
1008+
mod_t<L, R> operator%(expression_t<L> l, expression_t<R> r) {
1009+
return {std::move(l.value), std::move(r.value)};
1010+
}
10071011
}
10081012

10091013
template<class F, class O>

0 commit comments

Comments
 (0)