template<typename T>
class System::Comparison< T >
Represents a pointer to the method that compares two objects of the same type. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type.
#include "system/comparison.h"
#include "system/console.h"
#include "system/exceptions.h"
#include "system/string.h"
#include <algorithm>
#include <initializer_list>
#include <vector>
template <typename T>
class MyArray
{
std::vector<T> m_data;
public:
MyArray(const std::initializer_list<T>& source) : m_data(source) {};
{
if (comparison.IsNull())
{
throw ArgumentNullException(u"comparison");
}
std::sort(m_data.begin(), m_data.end(), comparison);
}
size_t get_Size()
{
return m_data.size();
}
{
if (index < 0 || index >= m_data.size())
{
throw IndexOutOfRangeException(u"index");
}
return m_data[index];
}
};
int main() {
MyArray<String> arr = {u"a", u"e", u"c", u"b", u"d"};
{
});
for (auto i = 0; i < arr.get_Size(); ++i)
{
}
return 0;
}
- Template Parameters
-
T | The type of the objects the method compares |