#include "condition.hpp"
#include "crud.hpp"
#include "expression.hpp"
-#include "tuple-helper.hpp"
#include "util.hpp"
#include <algorithm>
{
std::set<std::string> names;
- auto closure = [this, &names](const auto& type) {
+ auto predicate = [this, &names](const auto& type) {
Column anonymous("anonymous", type);
using TableType = typename decltype(anonymous)::Table;
auto name = this->getTableName(TableType());
names.emplace(name);
};
- auto tuple = std::tuple(columns...);
- tuple_helper::for_each(tuple, closure);
+ auto closure = [&predicate](const auto&... iter) {
+ (predicate(iter), ...);
+ };
+
+ std::apply(closure, std::tuple(columns...));
return std::vector<std::string>(names.begin(), names.end());
}
std::vector<std::string> Database<Tables...>::getColumnNames(Cs&& ...columns) const noexcept
{
std::vector<std::string> names;
- auto closure = [this, &names](const auto& iter) {
+ auto predicate = [this, &names](const auto& iter) {
auto name = this->getColumnName(iter);
if (!name.empty())
names.emplace_back(name);
};
- auto tuple = std::tuple(columns...);
- tuple_helper::for_each(tuple, closure);
+ auto closure = [&predicate](const auto&... iter) {
+ (predicate(iter), ...);
+ };
+
+ std::apply(closure, std::tuple(columns...));
return names;
}
std::string Database<Tables...>::getTableName(Table&& table) const noexcept
{
std::string name;
- auto predicate = [&name, &table](const auto& iter) {
- if (iter.compare(table))
- name = iter.name;
+ auto predicate = [&name, &table](const auto& type) {
+ if (type.compare(table))
+ name = type.name;
};
- tuple_helper::for_each(this->tables, predicate);
+ auto closure = [&predicate](const auto&... iter) {
+ (predicate(iter), ...);
+ };
+
+ std::apply(closure, this->tables);
return name;
}
}
};
- tuple_helper::for_each(this->tables, predicate);
+ auto closure = [&predicate](const auto&... iter) {
+ (predicate(iter), ...);
+ };
+
+ std::apply(closure, this->tables);
return name;
}
#include "column.hpp"
#include "crud.hpp"
-#include "tuple-helper.hpp"
#include "type.hpp"
#include "util.hpp"
std::vector<std::string> Table<Columns...>::getColumnNames(Cs&& ...columns) const noexcept
{
std::vector<std::string> names;
- auto closure = [this, &names](auto type) {
+ auto predicate = [this, &names](const auto& type) {
auto name = this->getColumnName(type);
if (!name.empty())
names.emplace_back(name);
};
- auto tuple = std::tuple(columns...);
- tuple_helper::for_each(tuple, closure);
+ auto closure = [&predicate](const auto&... iter) {
+ (predicate(iter), ...);
+ };
+
+ std::apply(closure, std::tuple(columns...));
return names;
}
std::vector<std::string> Table<Columns...>::getColumnNames(void) const noexcept
{
std::vector<std::string> names;
- auto closure = [&names](const auto& iter) {
- names.push_back(iter.name);
+ auto closure = [&names](const auto&... iter) {
+ (names.push_back(iter.name), ...);
};
- tuple_helper::for_each(this->columns, closure);
+ std::apply(closure, this->columns);
return names;
}
name = iter.name;
};
- tuple_helper::for_each(this->columns, predicate);
+ auto closure = [&predicate](const auto&... iter) {
+ (predicate(iter), ...);
+ };
+
+ std::apply(closure, this->columns);
return name;
}
+++ /dev/null
-/*
- * Copyright (c) 2017-present Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-#pragma once
-
-#include <tuple>
-
-namespace vist {
-namespace tsqb {
-namespace tuple_helper {
-namespace internal {
-
-template<int n, typename T, typename C>
-class Iterator {
-public:
- Iterator(const T& tuple, C&& closure) {
- Iterator<n - 1, T, C> iter(tuple, std::forward<C>(closure));
- closure(std::get<n-1>(tuple));
- }
-};
-
-template<typename T, typename C>
-class Iterator<0, T, C> {
-public:
- Iterator(const T&, C&&) {}
-};
-
-} // namespace internal
-
-template<typename T, typename C>
-void for_each(const T& tuple, C&& closure)
-{
- using Iter = internal::Iterator<std::tuple_size<T>::value, T, C>;
- Iter iter(tuple, std::forward<C>(closure));
-}
-
-} // namspace tuple-hepler
-} // namspace tsqb
-} // namspace vist