tables::gtable::reverse

template <typename... Ts,is_primitive_type... Ps,typename... Gs>
typename gtable<table<std::pair<Ts,Ps>...>,std::tuple<Gs...>>::gtable_t
gtable<table<std::pair<Ts,Ps>...>,std::tuple<Gs...>>::reverse() const

Returns gtable with sorted tables columns reversed.

Implementation calls table::reverse on each stored table.

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>,
  pair<c2,double>
>;


void gtable_reverse()
{
  const table_t t(
      {"abc", "def", "ghi", "abc", "def", "ghi"},
      {100,200,300,400,500,600},
      {1.0,2.0,3.0,4.0,5.0,6.0}
    );

  const auto gt = t.group_by<c0>().reverse();
  cout << gt << "\n";
}

Output

Col0|Col1 Col2
----|---------
 abc| 400    4
 abc| 100    1
 def| 500    5
 def| 200    2
 ghi| 600    6
 ghi| 300    3