473,804 Members | 2,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Will VC++ 2005 implement switch with case int::typeid in the final release?

With Visual C++ 2005 beta 2, I get the below compling error for the
following code. I think this error is not acceptable to me because
int::typeid is a constant and is known to compiler when compiling. Will VC++
2005 implement switch with case int::typeid in the final release?

error C2450: switch expression of type 'System::Type ^' is illegal

1> No user-defined-conversion operator available, or

1> Integral expression required

1>.\sproadapter .cpp(271) : error C2051: case expression not constant

Type ^t = obData->GetType();

switch (t)

{

case int::typeid:

break;

default:

break;

}
Nov 17 '05 #1
5 3118
I believe that C++ doesn't care about constantness, it just takes only int
(or type with implicit cast to int) argument.

"nobody" <no****@yahoo.c om> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
With Visual C++ 2005 beta 2, I get the below compling error for the
following code. I think this error is not acceptable to me because
int::typeid is a constant and is known to compiler when compiling. Will
VC++ 2005 implement switch with case int::typeid in the final release?

error C2450: switch expression of type 'System::Type ^' is illegal

1> No user-defined-conversion operator available, or

1> Integral expression required

1>.\sproadapter .cpp(271) : error C2051: case expression not constant

Type ^t = obData->GetType();

switch (t)

{

case int::typeid:

break;

default:

break;

}

Nov 17 '05 #2
nobody wrote:
With Visual C++ 2005 beta 2, I get the below compling error for the
following code. I think this error is not acceptable to me because
int::typeid is a constant and is known to compiler when compiling.
Will VC++ 2005 implement switch with case int::typeid in the final
release?


No.

System::Type is not an integer type and therefore cannot be used as the type
of a switch/case regardless of real or apparent const-ness.

-cd
Nov 17 '05 #3
Consider the following code:

Type ^t = obData->GetType();

if(t == int::typeid)

{

//do something

}

else if(t == __int64::typeid )

{

Type ^t = obData->GetType();

}

else if(t == double::typeid)

{

Type ^t = obData->GetType();

}

else if(t == float::typeid)

{

Type ^t = obData->GetType();

}

else

{

}

If I can use switch, it will much better. Do you know any method to use
switch?

"Carl Daniel [VC++ MVP]" <cp************ *************** **@mvps.org.nos pam>
wrote in message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
nobody wrote:
With Visual C++ 2005 beta 2, I get the below compling error for the
following code. I think this error is not acceptable to me because
int::typeid is a constant and is known to compiler when compiling.
Will VC++ 2005 implement switch with case int::typeid in the final
release?


No.

System::Type is not an integer type and therefore cannot be used as the
type of a switch/case regardless of real or apparent const-ness.

-cd

Nov 17 '05 #4
> Consider the following code:

If I can use switch, it will much better. Do you know any method to use
switch?


No, you can't. Depending on what you're doing you might be able to implement
a table driven approach, but that's about it.
--
Tomas Restrepo
to****@mvps.org
http://www.winterdom.com/
Nov 17 '05 #5
nobody wrote:
If I can use switch, it will much better. Do you know any method to use
switch?


While everyone else is correct that this is not supported by the C++
language, you can request that it be supported (see link to feedback below).
This request is very similar to another feature which we do not support --
switch on strings. C# supports switch on strings. The code generated in both
your case and the string case would effectively be a series of if-then-else
statements.

--
Brandon Bray, Visual C++ Compiler http://blogs.msdn.com/branbray/
Bugs? Suggestions? Feedback? http://msdn.microsoft.com/productfeedback/
Nov 17 '05 #6

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

Similar topics

14
23146
by: Medi Montaseri | last post by:
Hi, I think my problem is indeed "how to implement something like java's final in C++" The long version.... I have an abstract base class which is inherited by several concrete classes. I have a group of methods that I'd like to implement in the base class
1
1352
by: Peter Schmitz | last post by:
Hi, is there any specific release date for the Enterprise Architect Version of Visual Studio 2005? Thanks a lot Peter
2
1420
by: bis | last post by:
In the 11 November 2005 final "Visual Studio 2005" release called Whidbey (if I'm not wrong), will we have the Control Array back ? Time ago someone said no, then time later someother said yes... Now, have we the final answer?
5
1259
by: Cat | last post by:
Let's say I've compiled an application with .NET SDK 2.0 beta 2. If I didn't use any 2.0 feature, will the output exe run on .NET 1.1? That is, the source code is originally written for .NET 1.1. Another related question. If I build an application with the Visual Studio 2005 RTM, will the output exe run on .NET Framework redistributable 2.0 beta 2?
0
999
by: BM | last post by:
Hi, I have started to develop an web application, with VS 2005 beta 2. This application has many web forms mainly based on SQLDataSource and GridView, FormView, DetailView. Everithing done almost declaratively. Now I have migrated to VS 2005 Release Candidate, and SQL September CTP, both from PDC05. Now in my web application update action in GridView, FormView and DetailView in any web form simply don't update my data in database and...
1
1127
by: Sanjeev Kumar | last post by:
Hi, Where can I get the Visual Studio 2005 Final release and .Net Framework 2.0. I have a valid MSDN subscription ID from my organisation. Best Regards, Sanjeev
4
1044
by: Jared | last post by:
Hi, When do the betas finish?
12
1468
by: Peter Olcott | last post by:
Is there a .NET version of the standard Temple Library in Visual Studio .NET 2005? What is the 2005 updated equivalent of a std::vector in C# ?
6
1274
by: olrt | last post by:
Hello, I have a computer with VS.NET 2005 Beta2 (Team Edition) installed on it. I would like to uninstall .NET Framework 2.0 Beta and install .NET Framework 2.0 release. Is it risky ? Thanks for your answers. Olivier.
0
9572
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
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...
1
10303
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10070
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
9132
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
7608
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...
1
4282
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2978
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.