Solved

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

Posted on 2000-02-21
6
238 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
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

839 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