tables::table::deltas

1)

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

2)

template <typename... Ts,is_primitive_type... Ps>
inline
table<std::pair<Ts,Ps>...>
table<std::pair<Ts,Ps>...>::fill_with(const row_t& vals) const

3)

template <typename... Ts,is_primitive_type... Ps>
inline
table<std::pair<Ts,Ps>...>
table<std::pair<Ts,Ps>...>::zfill() const
  1. Returns table with nones replaced by previous non-none value.

  2. Returns table with nones replaced by provided vals.

  3. Returns table with nones replaced by zero.

Example

Code

#include <cpptables/table.hh>

using namespace tables;
using namespace std;

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

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



void table_fills()
{
  constexpr unsigned uint_none = prim_traits<unsigned>::none;
  constexpr double dbl_none = prim_traits<double>::none;

  const table_t t(
      {"abc", "def", "ghi", "foo", "bar"},
      {100,200,uint_none, 400, uint_none},
      {dbl_none, 2.0, 3.0, dbl_none, dbl_none}
    );

  using row_t = table_t::row_t;

  cout << t.fills() << "\n";
  cout << t.fill_with( row_t( "", 999, 9.9) ) << "\n";
  cout << t.zfill() << "\n";
}

Output

Col0 Col1 Col2
--------------
 abc  100 none
 def  200    2
 ghi  200    3
 foo  400    3
 bar  400    3

Col0 Col1 Col2
--------------
 abc  100  9.9
 def  200    2
 ghi  999    3
 foo  400  9.9
 bar  999  9.9

Col0 Col1 Col2
--------------
 abc  100    0
 def  200    2
 ghi    0    3
 foo  400    0
 bar    0    0