HiPipe  0.7.0
C++17 data pipeline with Python bindings.
copy.hpp
1 /****************************************************************************
2  * hipipe library
3  * Copyright (c) 2018, Iterait a.s.
4  * Author(s) Adam Blazek
5  *
6  * This file is distributed under the MIT License.
7  * See the accompanying file LICENSE.txt for the complete license agreement.
8  ****************************************************************************/
9 
10 #pragma once
11 
12 #include <hipipe/core/stream/transform.hpp>
13 
14 namespace hipipe::stream {
15 
37 template <typename... FromColumns, typename... ToColumns>
38 auto copy(from_t<FromColumns...> from_cols, to_t<ToColumns...> to_cols)
39 {
40  static_assert(sizeof...(FromColumns) == sizeof...(ToColumns),
41  "hipipe::stream::copy requires the same number of source and target columns.");
42 
43  static_assert(
44  ((std::is_constructible_v<typename FromColumns::example_type,
45  const typename ToColumns::example_type&>) && ...),
46  "hipipe::stream::copy target columns must be constructible "
47  "from the respective source columns.");
48 
49  return stream::transform(from_cols, to_cols,
50  [](const typename FromColumns::example_type&... vals) {
51  return utility::maybe_tuple<typename ToColumns::example_type...>(vals...);
52  });
53 }
54 
55 } // end namespace hipipe::stream
hipipe::stream::transform
auto transform(from_t< FromColumns... > f, to_t< ToColumns... > t, Fun fun, dim_t< Dim > d=dim_t< 1 >{})
Transform a subset of hipipe columns to a different subset of hipipe columns.
Definition: transform.hpp:218
hipipe::stream::copy
auto copy(from_t< FromColumns... > from_cols, to_t< ToColumns... > to_cols)
Copy the data from FromColumns to the respective ToColumns.
Definition: copy.hpp:43