tables::table::update_at
1)
template <typename... Ts,is_primitive_type... Ps>
template<typename... TUs,is_primitive_type... PUs>
requires (
( (in<TUs,std::tuple<Ts...>>) && ...) &&
( sizeof...(TUs) == sizeof...(PUs) ) &&
(
std::is_same_v< // TUs/PUs matches same pair in ts_t,ps_t
snd_elem_at_t<std::tuple<Ts...>,std::tuple<Ps...>,TUs>,
PUs
> && ...
)
)
inline
table<std::pair<Ts,Ps>...>
table<std::pair<Ts,Ps>...>::update_at(const vixs_t& ixs, const PUs... ctes) const
2)
template <typename... Ts,is_primitive_type... Ps>
template<typename... TUs,is_primitive_type... PUs>
requires (
( (in<TUs,std::tuple<Ts...>>) && ...) &&
( sizeof...(TUs) == sizeof...(PUs) ) &&
(
std::is_same_v< // TUs/PUs matches same pair in ts_t,ps_t
snd_elem_at_t<std::tuple<Ts...>,std::tuple<Ps...>,TUs>,
PUs
> && ...
)
)
inline
table<std::pair<Ts,Ps>...>
table<std::pair<Ts,Ps>...>::update_at(const vixs_t& ixs, const column<PUs>&... cs) const
-
Returns a new table obtained by updating columns TUs and at rows ixs using columns cs.
-
Returns a new table obtained by updating columns TUs and at rows ixs using scalar ctes.
Example
Code
#include <cpptables/table.hh>
#include <cpptables/where.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_update_at()
{
const table_t t(
{"abc", "def", "ghi", "abc", "def", "ghi"},
{100,200,300,400,500,600}
);
const column<unsigned> vals({1,2,3,4,5,6});
const auto t1 = t.update_at<c1>(
where( t.col<c0>() == string_view("abc") ),
vals
);
cout << t1 << "\n";
}