Removed 'reduce' from SemanticValues.

This commit is contained in:
yhirose 2015-03-05 21:59:54 -05:00
parent 4d65fc4c56
commit 81d7593ea1
2 changed files with 10 additions and 10 deletions

View File

@ -24,6 +24,15 @@ using namespace std;
// ~_ <- [ \t\r\n]* // ~_ <- [ \t\r\n]*
// //
template <typename T, typename U, typename F>
static U reduce(T i, T end, U val, F f) {
if (i == end) {
return val;
}
std::tie(val, i) = f(val, i);
return reduce(i, end, val, f);
};
struct ast_node struct ast_node
{ {
virtual ~ast_node() = default; virtual ~ast_node() = default;
@ -48,7 +57,7 @@ struct ast_ope : public ast_node
static shared_ptr<ast_node> create(const SemanticValues& sv) { static shared_ptr<ast_node> create(const SemanticValues& sv) {
assert(!sv.empty()); assert(!sv.empty());
return SemanticValues::reduce( return reduce(
sv.begin() + 1, sv.begin() + 1,
sv.end(), sv.end(),
sv[0].get<shared_ptr<ast_node>>(), sv[0].get<shared_ptr<ast_node>>(),

View File

@ -220,15 +220,6 @@ struct SemanticValues : protected std::vector<SemanticValue>
using std::vector<T>::emplace; using std::vector<T>::emplace;
using std::vector<T>::emplace_back; using std::vector<T>::emplace_back;
template <typename T, typename U, typename F>
static U reduce(T i, T end, U val, F f) {
if (i == end) {
return val;
}
std::tie(val, i) = f(val, i);
return reduce(i, end, val, f);
};
template <typename F> template <typename F>
auto map(F f) const -> vector<typename std::remove_const<decltype(f(SemanticValue()))>::type> { auto map(F f) const -> vector<typename std::remove_const<decltype(f(SemanticValue()))>::type> {
vector<typename std::remove_const<decltype(f(SemanticValue()))>::type> r; vector<typename std::remove_const<decltype(f(SemanticValue()))>::type> r;