the name of object declaired with type name compair

I am trying to make a wrapper class based on the map class.
I need to use the object declared with the third typename parameter, "_Compare", in the base map class

"map<key, value, compare>"

I looked in the header for map and found "comp", but when I try to compile I get the message
"error" comp was not declared in this scope. What is the name of the object I am trying to use?

1
2
3
4
5
6
7
8
9
10
11
12
13
template <class T, class U, class C>
class Xmap : public map<T, U, C>
{ 
	  
   public:
	  Xmap(map<T, U> *s_ ) { comp.set(s_);}; // comp should be the declaired object of the compare class
	  ~Xmap() {};
	  void set(map<T, U> *s_ ) 
	  { 
		  clear();
		  compare.set(s_); 
	  }; 
 };


The object declared with this typename has a member called set that I need to be able to chance during execution of code.

You are entering in implementation defined code.
¿Is this what you are talking about? http://cplusplus.com/reference/stl/map/value_comp/
It does not have a public set method...

¿What are you trying to do? ¿changing the comparison function in the middle of the game?
Besides that it will break everything, it could be a hard hack, because the map could be creating temporaries in order to perform the comparison.

>>¿Is this what you are talking about? http://cplusplus.com/reference/stl/map/value_comp/

maybe, how would I access this class within my wrapper class?
/*
*
* What I am trying to do is the following:
*
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

 //My compare class

template <class T, class U>
class map_sort 
{ 
   private:
      map<T, U>& s_map; 
   public:            
      map_sort( map<T, U>& s_ ) : s_map(s_) {}
      void set( map<T, U>& s_ ) {s_map = s_; }
      bool operator()(T x, T y) const
      { return s_map.at(x) < s_map.at(y); }
};
*
*main()
{
	Xmap<string, int, map_sort<string, int> > mymap5(tmap);
	// load and use mymap5
	mymap5.clear;
	mymap5.set(qmap);
	// load some other data to mymap5 using a different sorting map
}

*
* xmap is a wrapper class that will allow me to set up a method to access the set method in my compare class
Topic archived. No new replies allowed.