tables::table::deltas

template <typename... Ts,is_primitive_type... Ps>
inline
table<std::pair<Ts,Ps>...>
table<std::pair<Ts,Ps>...>::deltas() const

Return table where columns contain difference between consecutive elements.

The implementation calls deltas on each column.

Example

Code

#include <cpptables/table.hh>
#include <iostream>

using namespace tables;
using namespace std;

struct c0{ constexpr static string_view name =  "Col0"; };
struct c1{ constexpr static string_view name =  "Col1"; };

using table_t = table<
  pair<c0,double>,
  pair<c1,unsigned>
>;

void table_deltas()
{
  const table_t t(
      {10.0, 20.0, 30.0, 40.0, 50.0, 60.0},
      {3, 5, 7, 11, 13, 17}
    );
  
  cout << t.deltas() << "\n";
}

Output

Col0 Col1
---------
  10    3
  10    2
  10    2
  10    4
  10    2
  10    4