Skip to content

Commit

Permalink
revert to_vec changes for now
Browse files Browse the repository at this point in the history
this broke a lot of code in motis
  • Loading branch information
pablohoch committed Aug 15, 2024
1 parent 258cfac commit 77aac49
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions include/utl/to_vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ namespace utl {

template <typename Output, typename Container, typename UnaryOperation>
inline void transform_to(Container&& c, Output& out, UnaryOperation&& op) {
out.reserve(static_cast<std::size_t>(std::distance(begin(c), end(c))));
std::transform(begin(c), end(c), std::back_inserter(out),
out.reserve(
static_cast<std::size_t>(std::distance(std::begin(c), std::end(c))));
std::transform(std::begin(c), std::end(c), std::back_inserter(out),
std::forward<UnaryOperation>(op));
}

template <typename Output, typename Container, typename UnaryOperation>
inline auto transform_to(Container&& c, UnaryOperation&& op) -> Output {
Output v;
v.reserve(static_cast<std::size_t>(std::distance(begin(c), end(c))));
std::transform(begin(c), end(c), std::back_inserter(v),
v.reserve(
static_cast<std::size_t>(std::distance(std::begin(c), std::end(c))));
std::transform(std::begin(c), std::end(c), std::back_inserter(v),
std::forward<UnaryOperation>(op));
return v;
}
Expand All @@ -33,24 +35,22 @@ inline auto to_vec(It s, It e, UnaryOperation&& op)

template <typename Container, typename UnaryOperation>
inline auto to_vec(Container&& c, UnaryOperation&& op)
-> std::vector<std::decay_t<decltype(op(*begin(c)))>> {
using std::begin;
using std::end;
auto v = std::vector<std::decay_t<decltype(op(*begin(c)))>>{};
v.reserve(c.size());
std::transform(begin(c), end(c), std::back_inserter(v),
-> std::vector<std::decay_t<decltype(op(*std::begin(c)))>> {
auto v = std::vector<std::decay_t<decltype(op(*std::begin(c)))>>{};
v.reserve(
static_cast<std::size_t>(std::distance(std::begin(c), std::end(c))));
std::transform(std::begin(c), std::end(c), std::back_inserter(v),
std::forward<UnaryOperation>(op));
return v;
}

template <typename Container>
inline auto to_vec(Container&& c)
-> std::vector<std::decay_t<decltype(*begin(c))>> {
using std::begin;
using std::end;
auto v = std::vector<std::decay_t<decltype(*begin(c))>>{};
v.reserve(c.size());
std::copy(begin(c), end(c), std::back_inserter(v));
-> std::vector<std::decay_t<decltype(*std::begin(c))>> {
auto v = std::vector<std::decay_t<decltype(*std::begin(c))>>{};
v.reserve(
static_cast<std::size_t>(std::distance(std::begin(c), std::end(c))));
std::copy(std::begin(c), std::end(c), std::back_inserter(v));
return v;
}

Expand Down

0 comments on commit 77aac49

Please sign in to comment.