37 lines
688 B
C++
37 lines
688 B
C++
#ifndef PFOR_PFOR_EXPRESSION_ASEXPRESSION_H
|
|
#define PFOR_PFOR_EXPRESSION_ASEXPRESSION_H
|
|
|
|
#include "expression.h"
|
|
|
|
namespace pfor {
|
|
namespace expr {
|
|
|
|
/**
|
|
* @brief turn into Expression if not already one
|
|
*/
|
|
template<typename, typename=void> struct AsExpressionImpl;
|
|
|
|
template<typename T>
|
|
struct AsExpressionImpl<T, std::enable_if_t<isExpression<T>>> {
|
|
using type = T;
|
|
};
|
|
|
|
template<typename T>
|
|
struct AsExpressionImpl<T, std::enable_if_t<not isExpression<T>>> {
|
|
using type = Constant<T>;
|
|
};
|
|
|
|
template<typename T>
|
|
using AsExpression = typename AsExpressionImpl<T>::type;
|
|
|
|
}
|
|
|
|
template<typename T>
|
|
expr::AsExpression<std::decay_t<T>> xpr(T&& v) {
|
|
return {std::forward<T>(v)};
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|