Solved

Why can't I specialize on greater<> ???

Posted on 2000-02-21
6
212 Views
Last Modified: 2010-04-02
See http://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=10297032

In VC6 I can't specialize on the template greater<> from STL?
Read the above question history, and let me know what you think about it....

Luc
0
Comment
Question by:LucHoltkamp
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:ntdragon
Comment Utility
when you are using tamplate functions or class's
u should write before them
template<class t>

i mean if you"ll take stack.h
there is a class stack
then if i want to make a stack of int i should write:

stack<int> S;//stack of int's

and in the h file

is writen
template<class T>
class stack{
....
};

i hope i understood your question right
and answer it


0
 
LVL 7

Expert Comment

by:KangaRoo
Comment Utility
:)
0
 
LVL 3

Author Comment

by:LucHoltkamp
Comment Utility
Sorry ntdragon, but did you read the question
http://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=10297032   ?

This is not what I asked....
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 7

Expert Comment

by:KangaRoo
Comment Utility
Hi ntdragon,

This is about template (partial) specialization:

template<typename T1, typename T2>
class A
{
    // general template
};

template<typename T>
class A<T, T*>
{
   // specialization for instances where T2 has type T1*
};
0
 
LVL 7

Accepted Solution

by:
KangaRoo earned 10 total points
Comment Utility
So here is the answer; place the specialization in  namespace  std

namespace std {
   template<> class greater<const char*>
   {
       public: bool operator()(const char* p1, const char* p2) const  {/*Your implementation*/}
    };
};
0
 
LVL 3

Author Comment

by:LucHoltkamp
Comment Utility
Any ideas why it must be in namespace std?
Why cant I just specialize after
using namespace std....


0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now