MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / expression

Class expression

test/include/test.hpp:241–877  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239
240template <class T, class U, class Operator>
241struct expression
242{
243 T lhs;
244 U rhs;
245
246 friend std::ostream& operator<<(std::ostream& s, const expression& self)
247 {
248 print_stream(s, self.lhs);
249 s << " " << Operator::as_string() << " ";
250 print_stream(s, self.rhs);
251 return s;
252 }
253
254 friend decltype(auto) get_value(const expression& e) { return e.value(); }
255
256 decltype(auto) value() const { return Operator::call(get_value(lhs), get_value(rhs)); };
257
258 TEST_FOREACH_UNARY_OPERATORS(TEST_EXPR_UNARY_OPERATOR)
259 TEST_FOREACH_BINARY_OPERATORS(TEST_EXPR_BINARY_OPERATOR)
260};
261
262// TODO: Remove rvalue references
263template <class T, class U, class Operator>
264expression<T, U, Operator> make_expression(T&& lhs, U&& rhs, Operator)
265{
266 return {std::forward<T>(lhs), std::forward<U>(rhs)};
267}
268
269// TODO: Remove rvalue reference
270template <class T>
271lhs_expression<T> make_lhs_expression(T&& lhs)
272{
273 return lhs_expression<T>{std::forward<T>(lhs)};
274}
275
276template <class T, class Operator>
277lhs_expression<T, Operator> make_lhs_expression(T&& lhs, Operator)
278{
279 return lhs_expression<T, Operator>{std::forward<T>(lhs)};
280}
281
282template <class T, class Operator>
283struct lhs_expression
284{
285 T lhs;
286 explicit lhs_expression(T e) : lhs(std::move(e)) {}
287
288 friend std::ostream& operator<<(std::ostream& s, const lhs_expression& self)
289 {
290 std::string op = Operator::as_string();
291 if(not op.empty())
292 s << Operator::as_string() << " ";
293 print_stream(s, self.lhs);
294 return s;
295 }
296
297 friend decltype(auto) get_value(const lhs_expression& e) { return e.value(); }
298

Callers

nothing calls this directly

Calls 1

print_streamFunction · 0.70

Tested by

no test coverage detected