Skip to content

Commit

Permalink
Back to specific implementations (works!?)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed Jun 14, 2019
1 parent a759481 commit e1e806f
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/dart_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ namespace Sass {
// ##########################################################################
// Flatten `vector<vector<T>>` to `vector<T>`
// ##########################################################################
template <template<typename...> class R = std::vector,
typename Top,
typename Sub = typename Top::value_type>
R<typename Sub::value_type> flatten(const Top & all)
template <class T>
std::vector<T> flatten(std::vector<std::vector<T>>& all)
{
R<typename Sub::value_type> flat;
for (auto& sub : all) {
std::vector<T> flat;
for (std::vector<T>& sub : all) {
std::move(std::begin(sub), std::end(sub),
std::inserter(flat, std::end(flat)));
}
Expand All @@ -28,7 +26,6 @@ namespace Sass {
// Expands each element of this Iterable into zero or more elements.
// Calls a function on every element and ads all results to flat array
// ##########################################################################

template <class T>
std::vector<T> expand(std::vector<std::vector<T>> vec) {
std::vector<T> flattened;
Expand All @@ -54,14 +51,13 @@ namespace Sass {

// ##########################################################################
// ##########################################################################
template < class Top,
typename Sub = typename Top::value_type
>
Sub flattenInner(Top cnt)
template <class T>
std::vector<T>
flattenInner(std::vector<std::vector<T>> vec)
{
Sub list;
for (Sub sub : cnt) {
list.emplace_back(std::move(flatten(sub)));
std::vector<T> list;
for (auto sub : vec) {
list.push_back(flatten(sub));
}
return list;
}
Expand Down

0 comments on commit e1e806f

Please sign in to comment.