We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

C++ Container classes question (vectors, lists, etc)

red_sodium
red_sodium asked
on
Medium Priority
595 Views
Last Modified: 2013-12-14
For some really weird reason I am getting 2 errors in my vector.h and list.h header files for the C++ container classes. I am using Borland C++ Builder, but that shouldn't make any difference I don't think.

The errors are both:

"Could not find a match for 'std::max( unsigned int, unsigned int)'."

And point to where vector.h, list.h, etc, call the max function (called as just max with no namespace before it). I think the max function it should be using is in algorith.h, but I'm not sure why I'm getting errors as I changed nothing in any of these files, and it worked alright before. I have also tried "using std::vector", but that doesn't help.

Thanks in advance for any help.
Comment
Watch Question

Commented:
If you post the offending code it would be useful :)

Commented:
If you are not stating std::max then you can either fully qualify it or add

using std::max;

Either way, please post code :)

Author

Commented:
void initialize()
    {
        buffer_size =
           max((size_type)1,__RWSTD::__rw_allocation_size((value_type*)0,(size_type)0));
    }


That piece of code is in vector.h (~line 320 ), and it is the only line which gives me those 2 errors. The error does not appear when i only include vector.h, but it appears as soon as i define a vector:

vector<int> vInt;

Commented:
>> when i only include vector.h

You should not be doing this, you should be stating

#include <vector>

And I would not assume that there is anything wrong with the source code for vector; messing with those can lead to infinite problems.

Author

Commented:
Sorry, meant #include <vector>

I am assuming it is something wrong with my code, but I can't see what could possibly be wrong.

Commented:
OK.  I intially figured that the problem was when you try and call max(), but it know sounds like you get this "Could not find a match for 'std::max..." when you just declare a vector.  Correct ?

Author

Commented:
Yeah.

Commented:
Right that is very strange.  If you do not have another compiler paste your entire code here, or if you do try and compile it in that.

Author

Commented:
Sorry, it's too split up to post it all, but here's my includes.h header file:

#ifndef includesH
#define includesH

#include <vcl>
#include <windows>
#include <fstream>
#include <vector>
using std::vector;
#include "d3dx9.h"
#define WIN32_MEAN_AND_LEAN // Cut the fat from windows library

class EngineManager;
class DirectXSetup;

#include "defines.h"
#include "EngineManager.h"
#include "DirectXSetup.h"
//--------------------------------------------------------------------------
#endif


Commented:
>> #include <windows>

should be #include <windows.h> but I don't think that will make a difference.

I cannot see why you are getting the error you are then, sorry.  Hope someone else can !

Will post again if any ideas crop up.
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
>> Include <algorithm>
> hmm, not doing that in VC++ does not mean that I cannot declare a vector, but it may do in Borland.  We shall see...

I know it seems daft, but that's where the max template is defined and somehow or other you've not got it in your Borland setup.

I'd be wary of Alex's max macro. It could do unexpected things if the STL headers pass it a parameter with an increment operator.
>> I'd be wary of Alex's max macro. It could do unexpected things if the STL headers pass it a parameter with an increment operator.

That's right. That's why the macro __MUST__ be "#undef"ed before including any STL header.

Regards, Alex
Like...erm... <vector>??

Author

Commented:
Wow, this is so weird. It now works, without the need for any of these.

Could it be anything to do with my changing the priorities of my include folders, as this is the only thing I can think of which might have changed it...

Hmm, now I'm not sure what to do about the points...
I expect http:/Miscellaneous/Philosophy_Religion/ has the answer.
>> Could it be anything to do with my changing the priorities of my include folders

That is most likely. If you have a mix between old libraries as RoqueWave tools.h and new(er) one like Borland C++ and STL you should make the newer ones to have higher priority.

Regards, Alex
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.