tables::table::distinct

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

Return table with duplicate rows removed.

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,string_view>,
  pair<c1,unsigned>
>;

void table_distinct()
{
  const table_t t(
      {"abc","def","abc","ghi","ghi"},
      {10,20,10,30,40}
    );
  
  cout << t.distinct() << "\n";
}

Output

Col0 Col1
---------
 abc   10
 def   20
 ghi   30
 ghi   40