473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Specialization of what?

Hello all,

The code shown below is adapted from Mr. Sutter's Guru of the Week #49.

The 8'th definition of f() is a specialization. What is it a specialization
of (i.e., which is the primary template)???

Is there an answer? If so, is it moot or is the answer meaningful in some
functional way?

Thanks,
Dave

template<class T1, class T2> int f(T1, T2) {return 1;}

template<class T> int f(T) {return 2;}

template<class T> int f(T, T) {return 3;}

template<class T> int f(T*) {return 4;}

template<class T> int f(T*, T) {return 5;}

template<class T> int f(T, T*) {return 6;}

template<class T> int f(int, T*) {return 7;}

template<> int f<int>(int) {return 8;}

int f(int, double) {return 9;}

int f(int) {return 10;}


Jul 19 '05 #1
1 1298
"Dave Theese" <ch**********@yahoo.com> wrote...
The code shown below is adapted from Mr. Sutter's Guru of the Week #49.

The 8'th definition of f() is a specialization. What is it a specialization of (i.e., which is the primary template)???

Is there an answer? If so, is it moot or is the answer meaningful in some
functional way?

Thanks,
Dave

template<class T1, class T2> int f(T1, T2) {return 1;}

template<class T> int f(T) {return 2;}

template<class T> int f(T, T) {return 3;}

template<class T> int f(T*) {return 4;}

template<class T> int f(T*, T) {return 5;}

template<class T> int f(T, T*) {return 6;}

template<class T> int f(int, T*) {return 7;}

template<> int f<int>(int) {return 8;}

int f(int, double) {return 9;}

int f(int) {return 10;}


I believe (8) is a specialisation of (2). That's the only template
which has one type argument and whose sole function argument is a pure
type as well (not a pointer) and the same as the template type argument.

Wasn't there an answer given to that GotW? Search Google news archives,
I bet it has been discussed in comp.lang.c++.moderated...

Victor
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Paul MG | last post by:
Hi Template partial specialization always seems like a fairly straightforward concept - until I try to do it :). I am trying to implement the input sequence type (from Stroustrup section...
4
by: Dave Theese | last post by:
Hello all, I'm trying to get a grasp of the difference between specializing a function template and overloading it. The example below has a primary template, a specialization and an overload. ...
8
by: Agent Mulder | last post by:
Hi group, I have a problem with partial template specialization. In the code below I have a template struct Music with one method, play(), and three kinds of music, Jazz, Funk and Bach. When I...
4
by: TT \(Tom Tempelaere\) | last post by:
Comeau compiler complains (too few arguments for class template "B") at line *** #include <memory> template<typename T, size_t n> struct A {}; template<typename T, size_t n> struct B;
19
by: Nicolas Fleury | last post by:
Hi everyone, I would to know what do you think of this PEP. Any comment welcomed (even about English mistakes). PEP: XXX Title: Specialization Syntax Version: $Revision: 1.10 $...
4
by: Michael Sparks | last post by:
I started writing some code with the 2.0 beta compiler, and found out quickly that specialization is not supported with generics. For example, I want to do something like this: class number...
9
by: stephen.diverdi | last post by:
Can anyone lend a hand on getting this particular template specialization working? I've been trying to compile with g++ 4.1 and VS 2005. ...
8
by: flopbucket | last post by:
Hi, I want to provide a specialization of a class for any type T that is a std::map. template<typename T> class Foo { // ... };
1
by: Ioannis Gyftos | last post by:
Hello, First the code :) /////////////////////////////////////////////////////////////////////////////////// // in another header file namespace LJC{
6
by: abir | last post by:
i have a template as shown template<typename Sclass Indexer{}; i want to have a specialization for std::vector both const & non const version. template<typename T,typename Aclass...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.