CoryG89's Profile User Rating: -----

Reputation: 2 Apprentice
New Members
Active Posts:
9 (0.01 per day)
29-March 11
Profile Views:
Last Active:
User is offline May 25 2012 11:18 AM

Previous Fields

Dream Kudos:
Icon   CoryG89 has not set their status

Posts I've Made

  1. In Topic: Question about Queue/Stack Data Structures

    Posted 22 Apr 2012

    View Postishkabible, on 22 April 2012 - 06:23 PM, said:

    for C++98/03, you should pass it a constant reference and then copy that reference into the queue(using copy constructor preferably).

    void enqueue(const T& value);

    without proper care, C++ can be a bit copy happy. as a general rule, for things like these use a constant reference. that way an extra copy is only made if the user creates a creates a copy.

    This is what I had decided on after thinking about it and debugging to see what was going on. Thanks for the detailed answer. ^_^
  2. In Topic: Question about generic functions in C++ (vectors and templates)

    Posted 21 Apr 2012

    View Postishkabible, on 21 April 2012 - 05:09 PM, said:

    this literally has, *no* purpose. vectors, and many other things in C++, provide iterators. iterators allow for generic code to be written that works for vectors, lists, deques, maps, sets, complex classes like LLVM's module class(has like 4 different types of iterators), and an unbounded number of other data structures. you would be *FAR* better off just using the '=' operator of an std::vector *if* you absolutely needed a copy.

    I'm not sure what you mean by this. Are you saying that I shouldn't be trying to convert a templated vector object to a corresponding array? Or are you saying that there is a better way to do this. The code you gave simply assigned one vector to another.


    you can actually pretty easily convert your sorting algorithm to use iterators.

    Yes, I am aware of this and probably will sometime in the future. This was a quick fix to compare output results.
  3. In Topic: Question about generic functions in C++ (vectors and templates)

    Posted 21 Apr 2012

    View Postsepp2k, on 21 April 2012 - 04:03 PM, said:

    Do you have the function definition in the header file or in a c++ file? For templated functions the definition needs to be in the header file.

    Sure enough this was the problem. Thanks for the tip. Any insight as to why this is so with templated functions? Makes me tempted to put all the definitions in the header and just include that to be consistent.

My Information

Member Title:
New D.I.C Head
Age Unknown
Birthday Unknown

Contact Information



CoryG89 hasn't added any friends yet.


CoryG89 has no profile comments yet. Why not say hello?