/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include <algorithm>
using namespace std;
struct dane
{
int a;
string b;
float c;
};
bool operator<(const dane &d1, const dane &d2)
{
return d1.a < d2.a;
}
int main()
{
//to dla testu
const int SIZE = 10;
int buffer[SIZE] = { 5, 4, 3, 0, 9, 6, 7, 2, 8, 1 };
sort<int*>(buffer, buffer + SIZE);
for (int cnt = 0; cnt < SIZE; cnt++)
{
cout << buffer[cnt] << ", ";
}
cout << "\nbedzie wywrotka bo w buforze nie mam struktur dane";
//tak użyłbyś dla swojej struktury dane
sort<dane*>(reinterpret_cast<dane*>(buffer), reinterpret_cast<dane*>(buffer + SIZE - sizeof(dane)));
return 0;
}