I am unable to resolve the below code compilation issue:
class A
{
public:
int x;
};
void sort_A(TArray<A> &_Atype)
{
std::stable_sort (_Atype.begin(), _Atype.end());
}
bool operator< (const A & _a1, const A & _a2)
{
return _a1.x < _a2.x;
}
When we compile using gcc 4.1.2 on RH5.2 I am getting the below mentioned error:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h: In function �void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = A*]� not a class or a defined type:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:3066: instantiated from �void std::__inplace_stable_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = A*]�
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:3776: instantiated from �void std::stable_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = A*]�
instantiated from �void sortA(TArray<A>&)
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:2277: error: no match for �operator<� in �__val < * __first�
I tried all the way using {typedef , SmartPointer} to define the type but it constantly throws the above mentioned error. What and how should I should declare and define so that the type (A*) is known by compiler when calling std::stable_sort.
Please help.