473,408 Members | 2,832 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,408 software developers and data experts.

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 3086
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.com> wrote in message
news:%2****************@TK2MSFTNGP09.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.nospam >
wrote in message news:%2****************@tk2msftngp13.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
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...
1
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
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...
5
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. ...
0
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...
1
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
by: Jared | last post by:
Hi, When do the betas finish?
12
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
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...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
0
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...
0
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...

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.