Solved

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

Posted on 2000-02-21
6
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:ntdragon
ID: 2544104
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
ID: 2545119
:)
0
 
LVL 3

Author Comment

by:LucHoltkamp
ID: 2545126
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 7

Expert Comment

by:KangaRoo
ID: 2545128
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
ID: 2545168
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
ID: 2545460
Any ideas why it must be in namespace std?
Why cant I just specialize after
using namespace std....


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

632 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