I am unable to resolve the below code compilation issue:
Code:
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:
Code:
/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.
Last edited by Scott; 02-08-2010 at 10:56 AM..
Reason: Please use code tags
I have a question about iterators. Here is the code I have
template <typename element>
void merge_sort(vector<element> &v)
{
element::iterator lo;
}
Now thats all the code I have for the non-recursive merge sort at the moment, which obvioulsy isn't a lot, but I need... (0 Replies)
INFO:
The program should enter a circle radius and Id for that circle to a file, then it should search for that id and print the radius for that circle.
PROBLEM:
This program compiles but it's not searching properly.
Circle.h
#ifndef CIRCLE_H
#define CIRCLE_H
#include <iostream>... (0 Replies)
Is is possible to make STL-Iterator to work with user defined class ,like the one below?
#include <iostream>
#include <stdexcept>
using namespace std;
template <class T>
class Array
{
public:
T& operator (unsigned i) throw(out_of_range)
{ return data_; }
protected:
... (2 Replies)
I get following compile time errors on HP ITANIUM machine
"/opt/include_std/limit", line 268: error # 2321: data member initializer is not allowed
_RWSTD_STATIC_CONST (bool, is_specialized = false);
"/opt/include_std/rw/iterator", line 119: error # 2247: class template "std::iterator_traits"... (0 Replies)
Hi
I am new to expect. Please if any one can help on my issue its really appreciable. here is my issue:
I want expect script for random passwords and random commands generation.
please can anyone help me?
Many Thanks in advance (0 Replies)
Need to use dd to generate a large file from a sample file of random data. This is because I don't have /dev/urandom.
I create a named pipe then:
dd if=mynamed.fifo do=myfile.fifo bs=1024 count=1024
but when I cat a file to the fifo that's 1024 random bytes:
cat randomfile.txt >... (7 Replies)
Hello coders,
been running into an strange behavior into one of my script and i'm wondering if my code wouldn't be responsible.
Bash on rhel 5.7
This is a basic check to see if bind is up and running on server.
# rndc check
INFO="Checking rndc"
for DNS_SERVER in ${DNS_MASTER_SERVERS};... (10 Replies)
Hi, we have a FTP server on vSphere on a windows 2008 server platform.
One of our Unix machines now cannot send files to it, we checked permissions etc.
Can login, when using put events.txt it gives a 550 Access Denied error.
Nothing has changed from yesterday when it was working apart from... (1 Reply)
Discussion started by: RonT
1 Replies
LEARN ABOUT PHP
cachingiterator
CACHINGITERATOR(3) 1 CACHINGITERATOR(3)The CachingIterator classINTRODUCTION
This object supports cached iteration over another iterator.
CLASS SYNOPSIS
CachingIterator
CachingIteratorextends
IteratorIteratorOuterIteratorArrayAccessCountable
Constants
o const integer$CachingIterator::CALL_TOSTRING1
o const integer$CachingIterator::CATCH_GET_CHILD16
o const integer$CachingIterator::TOSTRING_USE_KEY2
o const integer$CachingIterator::TOSTRING_USE_CURRENT4
o const integer$CachingIterator::TOSTRING_USE_INNER8
o const integer$CachingIterator::FULL_CACHE256
Methods
o public CachingIterator::__construct (Iterator $iterator, [string $flags = self::CALL_TOSTRING])
o public int CachingIterator::count (void )
o public void CachingIterator::current (void )
o public array CachingIterator::getCache (void )
o public void CachingIterator::getFlags (void )
o public Iterator CachingIterator::getInnerIterator (void )
o public void CachingIterator::hasNext (void )
o public scalar CachingIterator::key (void )
o public void CachingIterator::next (void )
o public void CachingIterator::offsetExists (string $index)
o public void CachingIterator::offsetGet (string $index)
o public void CachingIterator::offsetSet (string $index, string $newval)
o public void CachingIterator::offsetUnset (string $index)
o public void CachingIterator::rewind (void )
o public void CachingIterator::setFlags (bitmask $flags)
o public void CachingIterator::__toString (void )
o public void CachingIterator::valid (void )
PREDEFINED CONSTANTS
o CachingIterator::CALL_TOSTRING -Convert every element to string.
o CachingIterator::CATCH_GET_CHILD -Don't throw exception in accessing children.
o CachingIterator::TOSTRING_USE_KEY - Use key for conversion to string.
o CachingIterator::TOSTRING_USE_CURRENT - Use current for conversion to string.
o CachingIterator::TOSTRING_USE_INNER - Use inner for conversion to string.
o CachingIterator::FULL_CACHE -Cache all read data.
PHP Documentation Group CACHINGITERATOR(3)