Why do I need to define these in std for my random access iterator???

Hi guys,
I have written my own iterator class, to support 1-d slices of 2-d matrices, 2-d slices of 3-d matrices, etc.
At first I wrote the class as a bidirectional iterator, but then I needed to extend it to random access so that I could pass these iterators to std::sort etc. No problem, I thought, I just needed to add friend operators for "iterator-iterator" and "iterator+/-distance".
So, I did that and tested the code with VS6 and various versions of g++, with no problems. Isn't STL great!
But I had endless problems with Studio 10. It kept griping that various mostly-internal-looking template functions were not defined. The only way I could get it to work was to define these:
#if (defined __SUNPRO_CC) && (__SUNPRO_CC <= 0x570)
namespace std
     template<typename T>          // Sigh
     typename matrixit<T>::
     difference_type distance(const matrixit<T>& a, const matrixit<T>& b) {
          return b-a;
     template<typename T>           // WTF?
     T* __value_type(const matrixit<T>&) {
          return static_cast<T*>(0);
     template<typename T>           // WTF?
     typename matrixit<T>::
     difference_type* __distance_type(const matrixit<T>&) {
          return static_cast<typename matrixit<T>::difference_type*>(0);
     template<typename T>           // WTF?
     typename matrixit<T>::
     iterator_category __iterator_category(const matrixit<T>&) {
          return typename matrixit<T>::iterator_category();
#endif
Why do I have to do this, or am I missing something in my iterator class (eg, typedefs), or do I need to derive it from something? Here is what it looks like:
template<typename T>
class matrixit
public:
     typedef T&                         reference;
     typedef T*                         pointer;
     typedef T                         value_type;
     typedef size_t                    size_type;
     typedef ptrdiff_t               difference_type;
     typedef std::random_access_iterator_tag iterator_category;
Ta, Simon.

Come on, it is not that hard to work around the limitations of Cstd. For what you show here, you can use:
namespace std {
template <class Iterator> struct iterator_traits
typedef typename Iterator::value_type value_type;
typedef typename Iterator::difference_type difference_type;
typedef typename Iterator::pointer pointer;
typedef typename Iterator::reference reference;
typedef typename Iterator::iterator_category iterator_category;
template <class T> struct iterator_traits<T*>
typedef T value_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef T& reference;
typedef random_access_iterator_tag iterator_category;
template <class T> struct iterator_traits<const T*>
typedef T value_type;
typedef ptrdiff_t difference_type;
typedef const T* pointer;
typedef const T& reference;
typedef random_access_iterator_tag iterator_category;
template <class ForwardIterator>
inline ptrdiff_t
distance (ForwardIterator first, ForwardIterator last)
ptrdiff_t n = 0;
__distance(first, last, n,
iterator_traits<ForwardIterator>::iterator_category());
return n;
template <class InputIterator, class T>
inline typename iterator_traits<InputIterator>::difference_type
count (InputIterator first, InputIterator last, const T& value)
typename iterator_traits<InputIterator>::difference_type result;
count(first,last,value,result);
return result;
template <class InputIterator, class Predicate>
inline typename iterator_traits<InputIterator>::difference_type
count_if (InputIterator first, InputIterator last, Predicate pred)
typename iterator_traits<InputIterator>::difference_type result;
count_if(first,last,pred,result);
return result;
template < class T >
inline typename T::value_type*
__value_type (const T&)
{ return (typename T::value_type*)(0); }
template < class T >
inline typename T::difference_type*
__distance_type(const T&)
{ return (typename T::difference_type*)(0); }
template < class T >
inline typename T::iterator_category
__iterator_category (const T&)
typename T::iterator_category tmp;
return tmp;
} // namespace std
For the missing constructor of vector with iterators, you can simply use std::copy with a back_insert_iterator.
The hardest thing to work around is probably the missing conversion between std::pair of various types (for instance with various constness when you use std::map), but it can still be handled by always specifying the type of the pair instead of relying on std::make_pair.
And if there is a thing you really don't know how to work around, you can always ask here...

Similar Messages

  • Why do we need to define RFC destination and user for material replication

    Dear Experts,
    why do we need to define RFC destination and user for material replication? Here we use crm middleware only for material replication. Could you please help me to understand it?
    regards,
    Ranjan

    Hello,
    As far as I know, you can use the same RFC destination already available in ECC to SRM to replicate materials.
    You can refer to note 720819.
    Regards,
    Ricardo

  • Why there is need to define processing code (we41/we42) in Idocs?

    Hi All,
      Why there is need to define the processing codes when we already have defined the processing function for the IDOC type & message type combinations via we57.

    Hi,
    http://help.sap.com/saphelp_nw04/helpdata/en/dc/6b804043d711d1893e0000e8323c4f/content.htm
    The inbound function module needs to be linked to the message type and the mess type needs to b linked to the appropriate process code at the partner oprofile level before  any scenario is enabled.
    Regards,
    Gayathri

  • What is variants...why we need to create these in bw for processchains run

    what is variants...why we need to create these in bw for processchains run

    Process Variant lets u select on what all Objects the process type need to process on.
    http://help.sap.com/saphelp_nw04/helpdata/en/6e/192756029db54192427cf6853c77a7/content.htm
    Ex : Create Index Variant will have the Cube name for which( Load ) the Indexes are created.

  • Why do i need to buy the same app for each device over and over again??

    why do i need to buy the same app for each device over and over again??
    and why cant i just pay for the app ones for all devices as long at it is with the same account??
    i hate that i have to oay for the same game or app three time one for ipad ones for iphone and ones for mac please do something about that apple..!!!

    First, you posted in the Mac App Store forum which are apps for the Mac OS X, not iOS devices.
    You do not need to re purchase your apps. Connect your iOS devices to your computer, launch iTunes. From the menu bar click Apps then click Sync
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • Why do I need original receipt (can't find) for repair when my tablet is in warranty.

    Why do I need original receipt (can't find) for repair when my tablet is in warranty.

    Hi 33fy,
    Welcome to the community! Since you're new please be sure that you have checked out our Discussion guidelines
    You may want to contact Sony Mobile from within your region, they may be able to help with a different alternative. Use the link in my signature to find appropriate contact details.
     - Official Sony Xperia Support Staff
    If you're new to our forums make sure that you have read our Discussion guidelines.
    If you want to get in touch with the local support team for your country please visit our contact page.

  • I need to download Acrobatt X Std. for reinstallation

    I need to download Acrobat X Std. for reinstallation
    Where do I find it and can you please provide a link?
    Here is my SN from what came with the Dell computer:
    <serial number removed by moderator>

    The trials are always for the product version that has all the features.
    Download the Pro version from http://www.adobe.com/go/tryacrobatpro/
    During installation, when it prompts you for the serial number, enter the serial number you have for Acrobat Std.
    The installer will recognize it and configure the software to run the standard version. Let us know if you run into any issues.

  • Why do we need MTP in the SIP trunk for CVP warm transfers

    Hi All,
    Why do we need to enable MTP in SIP trunk between CUCM and CVP for CVP based trasnfers???
    Thanks in advance!!
    Regards,
    Thammaya Gupta K.

    I saw also in the CDR logs that the IP Phone media transport going to CUBE is in G711.And as well in the wireshark capture of the IP communicator that the CUCM invoke to use the g711 codec but as per ITSP logs they are now in the g729.
    @ Jamie If I un-tick the MTP point required in SIP trunk will make the call leg from IP Phone to CUBE g729 (w/o hw resource), I have also tried to use g729 preferred originating codec, but still the IP Phone is using g711.
    I have seen a documentation states:
    " To configure G.729 codecs for use with a SIP trunk, you must use a hardware MTP or transcoder that supports the G.729 codec." - I read this on the CUCM help page under configuring SIP trunk setting.
    Our ultimate goal is to use g729 without using HW MTP/ transcoder.
    IP Phone ->CUCM SIP Trunk ->CUBE-> ITSP

  • Why do we need a new PA (PErsonnel Area)  for retirees?

    Hi guys,
    I have seen this at many organizations that they have a separate PA for retirees. Why do they do that? Please explain.
    Thanks,
    Jess..

    Hi Jessica,
    There are many groupings that are determined according to personnel area & subarea of employees including premiums, primary wage types, appraisals, leave types, time quotas, work schedules, pay scales, etc.
    Thus, if retirees have different rights than normal workers in one of these groupings, then making the retirees a separate personnel area or subarea would make sense.
    Regards,
    Dilek

  • Why do i need to declate methods two times for this program work

    Hi,
    why should i have to declare 2 times the methods
    public void mouseClicked(MouseEvent e) {    }
    public void mousePressed(MouseEvent e) {    }
    public void mouseReleased(MouseEvent e) {    }
    public void mouseEntered(MouseEvent e) { }
    public void mouseExited(MouseEvent e) {  }
    to make this program work? why when i declate 1 time this program doesn't work good?
    import java.awt.*;*
    import javax.swing.;
    import java.awt.datatransfer.*;
    import java.io.FileReader;
    import java.io.IOException;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseEvent;
    public class Main extends JPanel implements MouseListener {
    public Main() {
    super(new GridLayout(2,2));
    final JTextArea jt= new JTextArea("dear test :) ",5,20);
    FileReader reader = null;
    System.err.println("Error closing reader");
    exception.printStackTrace();
    JButton bu = new JButton("copiar");
    final Clipboard clipboard = getToolkit().getSystemClipboard();
    //new add
    add(nn);
    add(tt);
    bu.addMouseListener(new MouseListener() {
    public void mouseEntered(MouseEvent e) {
    StringSelection data = new StringSelection(jt.getText());
    clipboard.setContents(data, data);
    public void mouseClicked(MouseEvent e) {
    public void mousePressed(MouseEvent e) {
    public void mouseReleased(MouseEvent e) {
    public void mouseExited(MouseEvent e) {
    private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("TextDemo");
    public static void main(String[] args) {
    //Schedule a job for the event dispatch thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    public void mouseClicked(MouseEvent e) {    }
    public void mousePressed(MouseEvent e) {    }
    public void mouseReleased(MouseEvent e) {    }
    public void mouseEntered(MouseEvent e) { }
    public void mouseExited(MouseEvent e) {  }
    }

    import java.awt.;
    import javax.swing.;
    import java.awt.datatransfer.*;
    import java.io.FileReader;
    import java.io.IOException;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseEvent;
    public class Main extends JPanel implements MouseListener {
    public Main() {
    super(new GridLayout(2,2));
    final JTextArea jt= new JTextArea("dear test :) ",5,20);
    FileReader reader = null;
    System.err.println("Error closing reader");
    exception.printStackTrace();
    JButton bu = new JButton("copiar");
    final Clipboard clipboard = getToolkit().getSystemClipboard();
    //new add
    add(nn);
    add(tt);
    bu.addMouseListener(new MouseListener() {
    public void mouseEntered(MouseEvent e) {
    StringSelection data = new StringSelection(jt.getText());
    clipboard.setContents(data, data);
    public void mouseClicked(MouseEvent e) { }
    public void mousePressed(MouseEvent e) { }
    public void mouseReleased(MouseEvent e) {}
    public void mouseExited(MouseEvent e) { }
    private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("TextDemo");
    public static void main(String[] args) {
    //Schedule a job for the event dispatch thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    public void mouseClicked(MouseEvent e) { }
    public void mousePressed(MouseEvent e) { }
    public void mouseReleased(MouseEvent e) { }
    public void mouseEntered(MouseEvent e) { }
    public void mouseExited(MouseEvent e) { }
    } the problem is this line bu.addMouseListener(new MouseListener() {
    if i change this to bu.addMouseListener(this() {
    it gives error saying expected ')'
    and then doesn't compile.
    i just don't know why , although the program runs when i declare the methods two times,
    but i think it's better java code , if i learn it why is this error and correct it

  • Need to define multiple smtp servers for all accounts (1 for WIFI and MOBILE network)

    Hi.   I just bought a BB10 and so far, loving it.   My phone service provider is Telus but I do not use their email.   So when I am on the Telus network, my smtp server setting needs to be smtp.telus.net and when I am on WIFI, I need to point to smtp.cogeco.ca.   Home can I set this up?

    If I would have know this I would have bought an iPhone instead.  Actually, I will return the Z10 Monday and get the iPhone 5.   Enough is enough.

  • Why does FF need to create 10,000 folders for the cache? How do I make it go back into single folder mode?

    Before it was x:\\Cache\"stuff"...Simple easy to find files if you need to.
    Now its..
    x:\\Cache\X\x1\"a little stuff"
    x:\\Cache\X\xA\"a little more stuff"
    x:\\Cache\X\x0\"a even more little stuff"
    x:\\Cache\X\x9\" crap... I'm lost now""
    What is the purpose for the extra folders? I want to be able to revert it back to single folder mode.

    You would need to revert to Firefox 3.6.23 to have the old cache setup.
    The multiple cache folder setup is to allow for a larger cache which works more efficiently that earlier versions worked.

  • Why do I need broadband when I only ask for a phon...

    BT you are now confusing yourself..I ordered on November 1st a new phone line to be installed on November 26th, On November 27th nothing...28th nothing, 29th nothing - you get the picture - eventually after phone call 45 I was told that BT did not come on the 26th due to the snow which arrived on the 29th November.
    The BT openreach people are very busy and my phone connection is now back until Jan 4th AM I am further told after chasing (phone call 87) - 
    This morning I get an automated email about my broadband being set up on 4th Jan ??? - I did not request this service, just a simple phone line - get to the exchange flick the switch and all systems go.
    If you call my number you get a ringing sound (not on the handset) and no it is not switched to mute or off - because the phone line is not connected, or so it seems...
    BT tell me - you've got my details what are you doing - how are you going to resolve this and hundreds of other complaints - I am waiting on my phone line only...do the right thing.

    Hi Djreid67,
    I am sorry to hear about the delay with the activation of your telephone service. I do know with the recent bad weather that this has caused a few major service outages across our network and this unfortunately has tied up a lot of our engineers.
    I would like to take a look at you order to see if there is anything I can do to get your telephone service activated a bit sooner. Please could you drop me an email with any BT account or order details you have? My email address can be found by clicking on my profile.
    Please make sure to include a link to this post.
    Thanks
    Paddy,
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry but we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

  • Google maps, why did it change, and why do I need a different public transportation app for every city?

    Is there a way to get google maps back on my phone?  I can't have multiple routing apps for each destination I travel.

    Kevnjhayes wrote:
    Is there a way to get google maps back on my phone? 
    Sure!
    Go here on your device:
    https://maps.google.com

  • Why do I need to supply credit card info for a free app?

    I've owned a 4s for 1 1/2 years and downloaded many free apps.  Now, in the last week, I'm asked for my credit card information to download a free app?  What gives?

    In the world of digital financial transactions, the term "free" is a bit of a misnomer.  Everything has a purchase price.  The price in this case is 0.00.  In order to pay the price for the item, you must enter valid payment information.

Maybe you are looking for

  • Rentals "Not Authorized" to play on AppleTV

    All my iTunes purchased/synced content plays fine on my AppleTV. Tried to rent a movie yesterday evening, and, after downloading, when going to play the movie, all I get is the message: "Your Apple TV is not authorized to play this content." I've tri

  • Insert + Update code in 11g taking WAY longer than 9 ?

    Hi guys Hoping to get a few suggestions as to what might be causing a problem I'm having. I've got a routine in a form that was previously running against a version 9 database, and is now running against an 11g database. The routine has a series of c

  • Flash Player crash dumps

    since i installed flash player 11, my computer keeps crashing, going to memory dump at random times. the only way around this (other than remaining in safe mode) is to re-download flash player in safe mode and it allows the computer to come back to (

  • Nokia 5000d-2 Issue

    Hello everyone, I have a problem with my 5000d-2, when somebody calls me, the phone displays only the phone number of the person that's calling me, although I have that person in my contact list (phone memory not sim). Can somebody guide me trough th

  • Why won't After Effects boot after installing Flash 10?

    Since installing Flash 10 this morning, other Adobe Products (After Effects and Audition) fail to initialize media core and won't boot.  Photoshop boots okay.  Deleting Preference File in AE didn't help.  Restored OS to two days ago.  No help. Vista