473,883 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

why c++ not support typeof()?

Hi all

Q1:

On reading source code of STL, I just confuse about why c++ not support
such a pesudo code ?

//pesudo code
int a = new int()£»
Typeof(a) b = new Typeof(a)()£»
Q2£º

NOT about c++:

How to read older post? for sample some one write on year 2002?
I tried google , no lucky.

thank you .

your key9
Mar 20 '06
15 29347
Pavel Vozenilek wrote:
You may download the fresh CVS or wait couple
of weeks for Boost 1.34 where it'l be released.

The library uses native typeof where available
(gcc) and emulation elsewhere.
The compile times for emulated typeof may be high.


Even for emulated typeof the compile times are not greatly problematic
as, AFAIK, a lot of effort has been spent on this area. The main
hurdle, which is required for portability, is the need to register a
type( and maybe associated types) with the typeof mechanism. Of course
registration can be a No-op, in native mode, on those platforms that
also support the 'native' mode.

regards
Andy Little

Mar 21 '06 #11
REH wrote:
I seem to recall an explanation was given for using decltype over
typeof, but I cannot find it. The reason is not mentioned in N1705.


I think decltype preserves references, whereas typeof doesnt:

std::ostream& my_output();

decl_type(my_ou tput()) t1;
typeof(my_outpu t()) t2;

t1 is std::ostream&
t2 is std::ostream.

I think <---!!!

regards
Andy Little

Mar 21 '06 #12
Alf P. Steinbach wrote:
* Mi************* @tomtom.com:
It (typeof) may appear in the next version, although probably by
another name. (decltype,
IIRC, because
it's the *declared* type of 'a' that determines decltype(a))


Of course you may not know, but, if you do know, or someone, whose
brilliant idea was it to /yet again/ disregard existing practice?


What existing practice? The name part? Or the behavior? When the EWG
looked
at the existing practice, it was discovered that there are really two
things that
they try to achieve. Because of this, existing practice was
inconsistent. The
EWG liked both, but decided that you can't have both things and a
single name.
AFAIK, the idea is still to have

auto x = expr; // where the type of x is "what you expect" and
decltype(expr) // where decltype(x) is really the type from the
declaration.

to cover the two common typeof cases. Existing practice is pretty much
anything in between.

HTH,
Michiel Salters

Mar 21 '06 #13
* Mi************* @tomtom.com:
Alf P. Steinbach wrote:
* Mi************* @tomtom.com:
It (typeof) may appear in the next version, although probably by
another name. (decltype,
IIRC, because
it's the *declared* type of 'a' that determines decltype(a)) Of course you may not know, but, if you do know, or someone, whose
brilliant idea was it to /yet again/ disregard existing practice?


What existing practice? The name part?


The name part, since AFAIK there's no room for deviant behavior... ;-)

Or the behavior? When the EWG
looked
at the existing practice, it was discovered that there are really two
things that
they try to achieve. Because of this, existing practice was
inconsistent. The
EWG liked both, but decided that you can't have both things and a
single name.
AFAIK, the idea is still to have

auto x = expr; // where the type of x is "what you expect" and
decltype(expr) // where decltype(x) is really the type from the
declaration.

to cover the two common typeof cases. Existing practice is pretty much
anything in between.


Is it?

When I typed "gnu typeof" into the Firefox address line, I endeth up at
<url:
http://developer.apple .com/documentation/DeveloperTools/gcc-4.0.1/gcc/Typeof.html>.

I'm unaware of any existing practice that gives x above, in your
example, the /dynamic/ type of expr, or anything but the static type.

So this second thing you're referring to, I don't see it: what is it?

As I see it, there must be some COBOL saboteur on the committee...
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Mar 21 '06 #14
REH

an**@servocomm. freeserve.co.uk wrote:
REH wrote:
I seem to recall an explanation was given for using decltype over
typeof, but I cannot find it. The reason is not mentioned in N1705.


I think decltype preserves references, whereas typeof doesnt:

std::ostream& my_output();

decl_type(my_ou tput()) t1;
typeof(my_outpu t()) t2;

t1 is std::ostream&
t2 is std::ostream.

I think <---!!!

regards
Andy Little


Well, since there is no standard definition of typeof, who's to say.
GCC's version does not. decltype not only preserves references, if
given an lvalue it "returns" a reference type.

REH

Mar 21 '06 #15
Key9 wrote:
On reading source code of STL, I just confuse about why c++ not support
such a pesudo code ?


Indeed, why not have an operator which extracts type information from
an expression which can be used in a cast or declaration?

Because it would be way too easy to implement, and way too useful.

That is not the C and C++ way.

Mar 21 '06 #16

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

Similar topics

1
1738
by: Paul Reed | last post by:
Hello, I have a function that runs at load time and throws a an "Object Doesn't Support This Propertiy or Method" jscript error. The offending line is "if (type != "undefined") ". If I change the check to "type != """...I get no error...any ideas? var thePath = ""; var type = ""
4
299
by: Eric | last post by:
I need to do the following but it doesn't compile if(typeof(listBox1.Items) == typeof(string)){ return; } typeof(listBox1.Items) doesn't work at all. My listBox has 2 types of items in them and I need to know what kind of item a user clicked on so I can use it for drag and drop
9
5490
by: James Geurts | last post by:
Hey all... I posted this in the vs.net ide group too, but people are not answering, so I figured that it might be more appropriate here. I'm not sure if I'm adding a designer to my code properly. I'm only adding it to the tree node, where each custom tree node is then added to a normal tree control I'm trying to get an add-in to interact with the property window in VS.Net. Basically, I created a tool window containing a custom tree...
11
5628
by: Jason Kendall | last post by:
Why doesn't the new "IsNot" operator work in conjunction with 'Typeof'?
26
2147
by: Matt Kruse | last post by:
Are there any current browsers that have Javascript support, but not RegExp support? For example, cell phone browsers, blackberrys, or other "minimal" browsers? I know that someone using Netscape 3 would fall into this category, for example, but that's not a realistic situation anymore. And if such a condition exists, then how do you guys handle validation using regular expressions, if the browser lacks them? For example:
0
1403
by: onyxring | last post by:
I'm reposting this, because I had a bit of difficulty last time and think that it might have fallen through the cracks. If I'm posting to the wrong groups, please let me know. Surely someone has some experience with this... I've been building custom web controls in C# with VS2005. Currently I'm looking into adding design-time functionality and have reached a point where I need to generate code in the page the custom control is on. ...
20
9327
by: effendi | last post by:
I am testting the following code in firefox function fDHTMLPopulateFields(displayValuesArray, displayOrderArray) { var i, currentElement, displayFieldID, currentChild, nDisplayValues = displayValuesArray.length; for (i=0; i<nDisplayValues; i++) {
15
4241
by: RobG | last post by:
When using createEvent, an eventType parameter must be provided as an argument. This can be one of those specified in DOM 2 or 3 Events, or it might be a proprietary eventType. My problem is testing for support of particular eventTypes - the DOM 2 Events Interface DocumentEvent says that if the eventType is not supported, it throws a DOM exception. This makes testing rather tough - if you try something like: if (document &&...
2
4319
by: bips2008 | last post by:
The code seems to work fine in other browser but in IE it throws this error. This is very urgent for me and any help would be greatly appreciated For your convienence i have posted the code for the file. The portion that is not working is the star rating part <?php session_start(); include_once('includes/host_conf.php'); include_once('includes/db_connect.php'); include_once('includes/mysql.lib.php');...
0
9944
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11153
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10757
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10420
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9583
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7975
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5804
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6002
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4225
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.