Iterator help needed


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Iterator help needed
# 1  
Old 02-28-2005
Iterator help needed

I have a question about iterators. Here is the code I have

Code:
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 to get this small problem worked out first. I am trying to create this iterator called lo, which will be equal to v.begin(). The problem is when I compile that code above, I get the following error:

merge_sort.cc: In function `void merge_sort(std::vector<element,
std::allocator<_CharT> >&)':
merge_sort.cc:13: error: parse error before `;' token

Where is this parse error? What am I not doing correctly to create the iterator?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help needed

First of all, let me state that I am a windows admin. I have a windows share mounted to /mnt/server I need a script that will either login as sudo or perform commands with sudo rights. I need the script to copy all of the users /home folders to the mounted windows share. Now If I can... (2 Replies)
Discussion started by: EricM
2 Replies

2. HP-UX

Error in include_std/limit and include_std/rw/iterator

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)
Discussion started by: dodo_ind
0 Replies

3. Programming

Random Access Iterator Error

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... (4 Replies)
Discussion started by: uunniixx
4 Replies

4. Shell Programming and Scripting

Help on these two needed ...!!

Folks I need help on following two. 1. Say i am getting two values like this ::1:953 and :::8005 I need to replace "::" (first two colons with a * ).I can get these values in a variable.How to tweak this variable to separate out the way i want? Anything after third ":" should be set... (9 Replies)
Discussion started by: ak835
9 Replies

5. Programming

STL Iterator and user-defined class

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)
Discussion started by: johnbach
2 Replies

6. IP Networking

Help needed

Hi, Can anyone please tell me where I can get the small projects with source code based on client-server programming using sockets in unix :confused::confused::confused: Thanks in advance... (1 Reply)
Discussion started by: smartgupta
1 Replies

7. UNIX for Dummies Questions & Answers

little help needed..

hi everyone i'm a noob trying to learn unix language.. but seems like i got no leads on how to start.. i'm playing with the 'ps' command.. i'm trying to show the pid, ppid, username, command, cpu utilization (in desc order), process start time and process status.. all in a command.. am i able... (3 Replies)
Discussion started by: hilofat
3 Replies

8. Shell Programming and Scripting

Help needed

Hi, I am beginner writing shell script i am using korn shell. I wrote shell script through which i am passing system date as parameter to build.xml file but i need to write a function when i pass systemdate as parameter the function has to return its respective quarterly date . Can any one... (0 Replies)
Discussion started by: connectpramod
0 Replies

9. AIX

Little help needed.

Hello, I am quite new to AIX, but have Linux experience. Iam facing a peoblem with AIX 5.2 running on a 43p Model 150 (RS6000). I tried everyting and i cant have the network to run properly. :confused: /etc/hosts looks like this: 127.0.0.1 loopback localhost 192.168.XXX.XXX... (5 Replies)
Discussion started by: Netghost
5 Replies

10. Shell Programming and Scripting

Help is needed

Hi I'm trying to print a directories struct tree that will look like this: A _a _b _B __c __d __C ___e B _a _b I'm doing a recursion, but how can I know how much space is needed before printing after the recursion? (3 Replies)
Discussion started by: abcde
3 Replies
Login or Register to Ask a Question
std::reverse_iterator< _Iterator >(3)			     Library Functions Manual			     std::reverse_iterator< _Iterator >(3)

NAME
std::reverse_iterator< _Iterator > - SYNOPSIS
Inherits std::iterator< iterator_traits< _Iterator >::iterator_category, iterator_traits< _Iterator >::value_type, iterator_traits< _Iterator >::difference_type, iterator_traits< _Iterator >::pointer, iterator_traits< _Iterator >::reference >. Public Types typedef __traits_type::difference_type difference_type" typedef iterator_traits < _Iterator > ::iterator_category iterator_category" typedef _Iterator iterator_type typedef __traits_type::pointer pointer typedef __traits_type::reference reference typedef iterator_traits < _Iterator >::value_type value_type" Public Member Functions reverse_iterator () reverse_iterator (iterator_type __x) reverse_iterator (const reverse_iterator &__x) template<typename _Iter > reverse_iterator (const reverse_iterator< _Iter > &__x) iterator_type base () const reference operator* () const reverse_iterator operator+ (difference_type __n) const reverse_iterator & operator++ () reverse_iterator operator++ (int) reverse_iterator & operator+= (difference_type __n) reverse_iterator operator- (difference_type __n) const reverse_iterator & operator-- () reverse_iterator operator-- (int) reverse_iterator & operator-= (difference_type __n) pointer operator-> () const reference operator[] (difference_type __n) const Protected Types typedef iterator_traits < _Iterator > __traits_type" Protected Attributes _Iterator current Detailed Description template<typename _Iterator>class std::reverse_iterator< _Iterator > Bidirectional and random access iterators have corresponding reverse iterator adaptors that iterate through the data structure in the opposite direction. They have the same signatures as the corresponding iterators. The fundamental relation between a reverse iterator and its corresponding iterator i is established by the identity: * &*(reverse_iterator(i)) == &*(i - 1) * This mapping is dictated by the fact that while there is always a pointer past the end of an array, there might not be a valid pointer before the beginning of an array. [24.4.1]/1,2 Reverse iterators can be tricky and surprising at first. Their semantics make sense, however, and the trickiness is a side effect of the requirement that the iterators must be safe. Definition at line 96 of file stl_iterator.h. Member Typedef Documentation typedef iterator_traits< _Iterator >::iterator_category std::iterator< iterator_traits< _Iterator >::iterator_category , iterator_traits< _Iterator >::value_type , iterator_traits< _Iterator >::difference_type , iterator_traits< _Iterator >::pointer , iterator_traits< _Iterator >::reference >::iterator_category [inherited] One of the tag types. Definition at line 121 of file stl_iterator_base_types.h. typedef iterator_traits< _Iterator >::value_type std::iterator< iterator_traits< _Iterator >::iterator_category , iterator_traits< _Iterator >::value_type , iterator_traits< _Iterator >::difference_type , iterator_traits< _Iterator >::pointer , iterator_traits< _Iterator >::reference >::value_type [inherited] The type 'pointed to' by the iterator. Definition at line 123 of file stl_iterator_base_types.h. Constructor &; Destructor Documentation template<typename _Iterator> std::reverse_iterator< _Iterator >::reverse_iterator () [inline] The default constructor value-initializes member current. If it is a pointer, that means it is zero-initialized. Definition at line 120 of file stl_iterator.h. Referenced by std::reverse_iterator< _Iterator >::operator+(), and std::reverse_iterator< _Iterator >::operator-(). template<typename _Iterator> std::reverse_iterator< _Iterator >::reverse_iterator (iterator_type__x) [inline], [explicit] This iterator will move in the opposite direction that x does. Definition at line 126 of file stl_iterator.h. template<typename _Iterator> std::reverse_iterator< _Iterator >::reverse_iterator (const reverse_iterator< _Iterator > &__x) [inline] The copy constructor is normal. Definition at line 131 of file stl_iterator.h. template<typename _Iterator> template<typename _Iter > std::reverse_iterator< _Iterator >::reverse_iterator (const reverse_iterator< _Iter > &__x) [inline] A reverse_iterator across other types can be copied if the underlying iterator can be converted to the type of current. Definition at line 139 of file stl_iterator.h. Member Function Documentation template<typename _Iterator> iterator_type std::reverse_iterator< _Iterator >::base () const [inline] Returns: current, the iterator used for underlying work. Definition at line 146 of file stl_iterator.h. Referenced by std::operator==(). template<typename _Iterator> reference std::reverse_iterator< _Iterator >::operator* () const [inline] Returns: A reference to the value at --current This requires that --current is dereferenceable. Warning: This implementation requires that for an iterator of the underlying iterator type, x, a reference obtained by *x remains valid after x has been modified or destroyed. This is a bug: http://gcc.gnu.org/PR51823 Definition at line 160 of file stl_iterator.h. Referenced by std::reverse_iterator< _Iterator >::operator->(). template<typename _Iterator> reverse_iterator std::reverse_iterator< _Iterator >::operator+ (difference_type__n) const [inline] Returns: A reverse_iterator that refers to current - __n The underlying iterator must be a Random Access Iterator. Definition at line 231 of file stl_iterator.h. References std::reverse_iterator< _Iterator >::reverse_iterator(). template<typename _Iterator> reverse_iterator& std::reverse_iterator< _Iterator >::operator++ () [inline] Returns: *this Decrements the underlying iterator. Definition at line 181 of file stl_iterator.h. template<typename _Iterator> reverse_iterator std::reverse_iterator< _Iterator >::operator++ (int) [inline] Returns: The original value of *this Decrements the underlying iterator. Definition at line 193 of file stl_iterator.h. template<typename _Iterator> reverse_iterator& std::reverse_iterator< _Iterator >::operator+= (difference_type__n) [inline] Returns: *this Moves the underlying iterator backwards __n steps. The underlying iterator must be a Random Access Iterator. Definition at line 241 of file stl_iterator.h. template<typename _Iterator> reverse_iterator std::reverse_iterator< _Iterator >::operator- (difference_type__n) const [inline] Returns: A reverse_iterator that refers to current - __n The underlying iterator must be a Random Access Iterator. Definition at line 253 of file stl_iterator.h. References std::reverse_iterator< _Iterator >::reverse_iterator(). template<typename _Iterator> reverse_iterator& std::reverse_iterator< _Iterator >::operator-- () [inline] Returns: *this Increments the underlying iterator. Definition at line 206 of file stl_iterator.h. template<typename _Iterator> reverse_iterator std::reverse_iterator< _Iterator >::operator-- (int) [inline] Returns: A reverse_iterator with the previous value of *this Increments the underlying iterator. Definition at line 218 of file stl_iterator.h. template<typename _Iterator> reverse_iterator& std::reverse_iterator< _Iterator >::operator-= (difference_type__n) [inline] Returns: *this Moves the underlying iterator forwards __n steps. The underlying iterator must be a Random Access Iterator. Definition at line 263 of file stl_iterator.h. template<typename _Iterator> pointer std::reverse_iterator< _Iterator >::operator-> () const [inline] Returns: A pointer to the value at --current This requires that --current is dereferenceable. Definition at line 172 of file stl_iterator.h. References std::reverse_iterator< _Iterator >::operator*(). template<typename _Iterator> reference std::reverse_iterator< _Iterator >::operator[] (difference_type__n) const [inline] Returns: The value at current - __n - 1 The underlying iterator must be a Random Access Iterator. Definition at line 275 of file stl_iterator.h. Author Generated automatically by Doxygen for libstdc++ from the source code. libstdc++ Tue Jun 10 2014 std::reverse_iterator< _Iterator >(3)