tables::table::reverse

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

Returns table with rows in reverse order.

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

void table_reverse()
{
  const table_t t(
      {"abc","def","ghi", "abc","def","ghi"},
      {10.0, 20.0, 30.0, 40.0, 50.0, 60.0}
    );
  
  cout << t.reverse() << "\n";
}

Output

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