tables::table::add

1)

template <typename... Ts,is_primitive_type... Ps>
template<typename... TAs,is_primitive_type... PAs>
requires (
  (!in<TAs,std::tuple<Ts...>> && ... ) &&
  is_tuple_unique<std::tuple<TAs...>> &&
  ( sizeof...(TAs) == sizeof...(PAs) )
)
inline
constexpr auto
table<std::pair<Ts,Ps>...>::add(const column<PAs>&... cs) const

2)

template <typename... Ts,is_primitive_type... Ps>
template<typename... TAs,is_primitive_type... PAs>
requires (
  (!in<TAs,std::tuple<Ts...>> && ... ) &&
  is_tuple_unique<std::tuple<TAs...>> &&
  ( sizeof...(TAs) == sizeof...(PAs) )
)
inline
constexpr auto
table<std::pair<Ts,Ps>...>::add(
  const table<std::pair<TAs,PAs>...>& t) const

  1. Returns new table obtained by adding the column(s) to the right of existing table.

  2. Returns new table obtained by adding columns of t to the right of existing table.

The lookup-types used must not already be present in table. To add-or-update, use addu, to update an existing column use update, or update_at.

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"; };
struct c2{ constexpr static string_view name =  "Col2"; };

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

void table_add()
{
  const table_t t(
      {"abc", "def", "ghi"},
      {100,200,300}
    );

  using table1_t = 
    table_t::add_t<pair<c2,double>>; // type of table with c2 column added

  const table1_t t1 = t.add<c2>( column<double>({1.0, 2.0, 3.0}) );
  cout << t1 << "\n";
}

Output

Col0 Col1 Col2
--------------
 abc   10    1
 def   20    2
 ghi   30    3