#include <iostream>
#include <algorithm>
struct myarray
{
myarray(unsigned size) : _size(size), _array(new int[_size]()) {}
unsigned size() const { return _size; }
int& operator[](unsigned index) { return _array[index]; }
int operator[](unsigned index) const { return _array[index]; }
operator int*() {return _array;}
operator const int*() const { return _array; }
myarray(const myarray&) = delete;
void operator=(const myarray&) = delete;
private:
unsigned _size;
int* _array;
};
void mysort(int* arr, unsigned sz) { std::sort(arr, arr + sz); }
void mysort(myarray& arr) { return mysort(arr, arr.size()); }
void display(const myarray& arr)
{
for (unsigned i = 0; i < arr.size(); ++i)
std::cout << arr[i] << '\n';
std::cout << '\n';
}
int main()
{
myarray arr(10);
for (unsigned i = 0; i < arr.size(); ++i)
arr[i] = arr.size() - i;
display(arr);
mysort(arr);
display(arr);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKc3RydWN0IG15YXJyYXkKewogICAgbXlhcnJheSh1bnNpZ25lZCBzaXplKSA6IF9zaXplKHNpemUpLCBfYXJyYXkobmV3IGludFtfc2l6ZV0oKSkge30KCiAgICB1bnNpZ25lZCBzaXplKCkgY29uc3QgeyByZXR1cm4gX3NpemU7IH0KICAgIGludCYgb3BlcmF0b3JbXSh1bnNpZ25lZCBpbmRleCkgeyByZXR1cm4gX2FycmF5W2luZGV4XTsgfQogICAgaW50IG9wZXJhdG9yW10odW5zaWduZWQgaW5kZXgpIGNvbnN0IHsgcmV0dXJuIF9hcnJheVtpbmRleF07IH0KCiAgICBvcGVyYXRvciBpbnQqKCkge3JldHVybiBfYXJyYXk7fQogICAgb3BlcmF0b3IgY29uc3QgaW50KigpIGNvbnN0IHsgcmV0dXJuIF9hcnJheTsgfQoKICAgIG15YXJyYXkoY29uc3QgbXlhcnJheSYpID0gZGVsZXRlOwogICAgdm9pZCBvcGVyYXRvcj0oY29uc3QgbXlhcnJheSYpID0gZGVsZXRlOwoKcHJpdmF0ZToKICAgIHVuc2lnbmVkIF9zaXplOwogICAgaW50KiBfYXJ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