473,558 Members | 3,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

template syntax.../ resent

Hi all,

I just hit the following definition in a c++ API:

template <class Str> template <class T, class B>
mysql_ColData<S tr>::operator Null<T,B> () const {
if ((*this)[0] == 'N' && (*this)[1] == 'U' &&
(*this)[2] == 'U' && (*this)[3] == 'L' && (*this).size() == 4)
return Null<T,B>(null) ;
else return Null<T,B>(conv( T()));
}

Is the first line equivalent to
template <class Str, class T, class B> ?

Are both syntax compliant to c++ standards?

cheers

regard

phf
Jul 23 '05 #1
2 1219
pa************* *@noos.fr wrote:
Hi all,

I just hit the following definition in a c++ API:

template <class Str> template <class T, class B>
mysql_ColData<S tr>::operator Null<T,B> () const {
if ((*this)[0] == 'N' && (*this)[1] == 'U' &&
(*this)[2] == 'U' && (*this)[3] == 'L' && (*this).size() == 4)
return Null<T,B>(null) ;
else return Null<T,B>(conv( T()));
}

Is the first line equivalent to
template <class Str, class T, class B> ?
No, the first is the beginning of the definition of a nested template: the outer
template, a class template mysql_ColData, has a single template parameter Str;
the inner template, a template conversion operator, has two template parameters
T and B.
Are both syntax compliant to c++ standards?
In different contexts, yes.
phf


Jonathan
Jul 23 '05 #2
Jonathan Turkanis wrote:

Thanks for your fast and precise answer...
phf
pa************* *@noos.fr wrote:
Hi all,

I just hit the following definition in a c++ API:

template <class Str> template <class T, class B>
mysql_ColData <Str>::operat or Null<T,B> () const {
if ((*this)[0] == 'N' && (*this)[1] == 'U' &&
(*this)[2] == 'U' && (*this)[3] == 'L' && (*this).size() == 4)
return Null<T,B>(null) ;
else return Null<T,B>(conv( T()));
}

Is the first line equivalent to
template <class Str, class T, class B> ?

No, the first is the beginning of the definition of a nested template: the outer
template, a class template mysql_ColData, has a single template parameter Str;
the inner template, a template conversion operator, has two template parameters
T and B.

Are both syntax compliant to c++ standards?

In different contexts, yes.

phf

Jonathan

Jul 23 '05 #3

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

Similar topics

699
33511
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it...
0
327
by: AdamKadmon | last post by:
Hello Group, Below is (mostly)functional code that enumerates certain properties for all of the groups in my Active Directory. My question is contained within comments as well as here: Once I have assigned the value of Properties to a variable and spit that value out to the console (ideally to a Stored Proc) and the foreach loops again,...
4
1811
by: Howard Gardner | last post by:
// I think that there is no way to write the template "cant_write_me" in // this example. Would love to be wrong. // one of many approaches that won't work template< template< typename class struct cant_write_me{}; template< template< typename, typename class struct cant_write_me{}; template< typename struct arity_one{}; template<...
5
2355
by: chrisstankevitz | last post by:
Hi, Q1: Is there a way to make a template function that works only for specific types which produces a compiler error if used with an invalid type? Q2: If not, how do people deal with this issue? I believe A1 is no. I tried below with template function "f". For A2, functors work but have ugly syntax and runtime overhead. A
2
3915
by: Nick | last post by:
I'm learning C++ and ran into a compile error using Visual C++ 2005 Express on the following example program (located at http://www.cplusplus.com/doc/tutorial/templates.html): // template specialization #include <iostream> using namespace std; template <class T> class container {
2
1998
by: adrian.hawryluk | last post by:
Hi everyone, I've been using templates for a while, but I'm not at full power yet (knowledge=power) ;). Does anyone know where I can get information on this 'new' template usage? template<a (b, c, d)> Does one define it like:
2
2196
by: Gary Nastrasio | last post by:
I'm currently reading Andrei Alexandrescu's book "Modern C++ Design" and I'm a bit confused by one bit of template syntax in chapter 1. Here is a code example: template <class CreationPolicy> class WidgetManager : public Creation Policy {...} // Create an instance of WidgetManager which managers type Widget WidgetManager<...
9
1954
by: Adam Nielsen | last post by:
Hi all, I'm a bit confused about the syntax used to access a nested template class. Essentially I have a bunch of class types to represent different types of records in a database, and I want to store some cache data for each datatype. The simplified code below demonstrates my issue - I think I understand why it doesn't work as is (the...
7
5758
by: QiongZ | last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it compiled no problem. But I can't find the what the problem is with templates? Please help. The main is in test-linked-list.cpp. There are two template...
0
7629
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7550
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8061
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7593
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6184
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5455
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5172
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3603
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3579
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.