Skip to content

Instantly share code, notes, and snippets.

@bkuhns
Last active December 13, 2015 20:18
Show Gist options
  • Save bkuhns/4968512 to your computer and use it in GitHub Desktop.
Save bkuhns/4968512 to your computer and use it in GitHub Desktop.
// main()
course.where(course.name == "Argh" && course.name == "Test");
//////////////////////
// FieldExpression.h
//////////////////////
// && operator for two FieldExpression<>'s.
template<typename L, typename R>
auto operator&&(const FieldExpression<Field<L>, L>& lhs, const FieldExpression<Field<R>, R>& rhs) -> decltype( MakeFieldExpression(lhs, OpAnd, rhs) )
{
return MakeFieldExpression(lhs, OpAnd, rhs);
}
template<typename LHS, typename RHS>
std::string FieldExpression<LHS, RHS>::toString() const
{
ostringstream str;
str << "(" << lhs_.toString() << ") " << operatorToString(operator_) << " (" << rhs_.toString() << ")";
return str.str();
}
/**************
*** OUTPUT ***
**************/
SELECT * FROM `Course` WHERE (`Course.name` = 'Argh') AND (`Course.name` = 'Test')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment